mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
scripts: rfr: Fix merge commit bug
The file +/- computation in the function that generates the email message text expects there to be files present in the git/gerrit commit object. But for merge commits there are no files present in the merge commit itself. A max() function ended up getting an empty list as an argument and then caused a crash. Fix this by checking to make sure there's actually files present in this list before passing it on to max(). If there are no files then just continue. Change-Id: Icd74234676ff3be6edb7fe65913970fd7a0aaff1 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2226035 Reviewed-by: Thomas Fleury <tfleury@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
20
scripts/rfr
20
scripts/rfr
@@ -302,18 +302,28 @@ Thanks!
|
|||||||
for c in commits_info:
|
for c in commits_info:
|
||||||
# note: x['deletions'] is negative (or zero)
|
# note: x['deletions'] is negative (or zero)
|
||||||
files = c['currentPatchSet']['files']
|
files = c['currentPatchSet']['files']
|
||||||
width = max([
|
file_widths = [
|
||||||
len(x['file']) for x in files if x['file'] != u'/COMMIT_MSG'])
|
len(x['file']) for x in files if x['file'] != u'/COMMIT_MSG']
|
||||||
file_template = "{name: <{width}} | {sum:<3} (+{adds: <3} -{dels: <3})"
|
|
||||||
|
# For merge commits there are no files in the commit itself. So this
|
||||||
|
# causes the below max() operation to choke. Given that there are no
|
||||||
|
# files it makes little sense for us to try and fill in any file
|
||||||
|
# details!
|
||||||
|
if file_widths:
|
||||||
|
width = max(file_widths)
|
||||||
|
file_template = ("{name: <{width}} | " +
|
||||||
|
"{sum:<3} (+{adds: <3} -{dels: <3})")
|
||||||
files_changed_desc = [file_template.format(
|
files_changed_desc = [file_template.format(
|
||||||
name=x['file'],
|
name=x['file'],
|
||||||
width=width,
|
width=width,
|
||||||
sum=x['insertions'] - x['deletions'],
|
sum=x['insertions'] - x['deletions'],
|
||||||
adds=x['insertions'],
|
adds=x['insertions'],
|
||||||
dels=-x['deletions'])
|
dels=-x['deletions'])
|
||||||
for x in files
|
for x in files if x['file'] != u'/COMMIT_MSG'
|
||||||
if x['file'] != u'/COMMIT_MSG'
|
|
||||||
]
|
]
|
||||||
|
else:
|
||||||
|
files_changed_desc = ''
|
||||||
|
|
||||||
cmt_verbose += cmt_template.format(url=c['url'],
|
cmt_verbose += cmt_template.format(url=c['url'],
|
||||||
author=c['owner']['name'],
|
author=c['owner']['name'],
|
||||||
cmtmsg=indent_lines(
|
cmtmsg=indent_lines(
|
||||||
|
|||||||
Reference in New Issue
Block a user