From 05e3be8177da3de355e2d2c3442942f4d6e61da9 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Fri, 15 Feb 2019 13:42:02 +0200 Subject: [PATCH] gpu: nvgpu: rfr: print file statistics Add a listing of changed files after the commit messages similar to how git show --stat would put it. This makes it trivial to see where the changes happened if the commit description doesn't state it. Example from this patch: scripts/rfr | 23 (+20 -3 ) The numbers are padded to a width of three so they line up nicely. Change-Id: Ie62ea6c7d1d3b21446c7447f362d148be3032076 Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/2020196 GVS: Gerrit_Virtual_Submit Reviewed-by: Philip Elcan Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- scripts/rfr | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/rfr b/scripts/rfr index aa2076a3d..9815bd633 100755 --- a/scripts/rfr +++ b/scripts/rfr @@ -59,7 +59,7 @@ user = os.environ['USER'] # Gerrit query command to obtain the patch URL. The substitution will be the # gerrit Change-ID parsed from the git commit message. -gr_query_cmd = 'ssh %s@git-master -p 29418 gerrit query --format json %s' +gr_query_cmd = 'ssh %s@git-master -p 29418 gerrit query --format json --current-patch-set --files %s' def parse_args(): """ @@ -283,7 +283,8 @@ Thanks! | {url} | Author: {author} -{cmtmsg}""" +{cmtmsg} +{files}""" cmt_descriptions = '' for c in commits_info: @@ -298,10 +299,26 @@ Thanks! cmt_verbose = '' for c in commits_info: + # note: x['deletions'] is negative (or zero) + files = c['currentPatchSet']['files'] + width = max([ + len(x['file']) for x in files if x['file'] != u'/COMMIT_MSG']) + file_template = "{name: <{width}} | {sum:<3} (+{adds: <3} -{dels: <3})" + files_changed_desc = [file_template.format( + name=x['file'], + width=width, + sum=x['insertions'] - x['deletions'], + adds=x['insertions'], + dels=-x['deletions']) + for x in files + if x['file'] != u'/COMMIT_MSG' + ] cmt_verbose += cmt_template.format(url=c['url'], author=c['owner']['name'], cmtmsg=indent_lines( - c['commitMessage'], ' ')) + c['commitMessage'], ' '), + files=' ' + "\n ".join( + files_changed_desc)) return whole_template.format(cmt_descriptions=cmt_descriptions, extra_message=extra_message,