mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
scripts: rfr: Add file support
Add support for reading a file full of commit IDs/URLs. This makes generating an RFR from a long list of commits easier in some cases. Change-Id: Id71173853e29d951048e8c3394ffce5d8b1eeb52 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1576523 Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@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:
committed by
mobile promotions
parent
2b2b4f9b14
commit
138e70b0d4
46
scripts/rfr
46
scripts/rfr
@@ -13,7 +13,7 @@ import smtplib
|
||||
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
VERSION = '1.0.0'
|
||||
VERSION = '1.0.1'
|
||||
|
||||
# Gerrit commit URL formats. These are regular expressions to match the
|
||||
# incoming URLs against.
|
||||
@@ -65,10 +65,12 @@ Otherwise it's treated as a git commit ID.
|
||||
parser.add_argument('-t', '--to', action='append', default=[],
|
||||
help='Specify an additional To: email address. '
|
||||
'Can be repeated (-t a -t b).')
|
||||
parser.add_argument('-F', '--file', action='store', default=None,
|
||||
help='File with commits, one per line')
|
||||
|
||||
# Positionals: the gerrit URLs.
|
||||
parser.add_argument('commits', metavar='Commit-IDs',
|
||||
nargs='+',
|
||||
nargs='*',
|
||||
help=help_msg)
|
||||
|
||||
arg_parser = parser.parse_args()
|
||||
@@ -89,6 +91,32 @@ def get_gerrit_url_id(cmt):
|
||||
|
||||
return None
|
||||
|
||||
def read_commit_file(filp):
|
||||
"""
|
||||
Read a file full of commits and return a list of those commits.
|
||||
"""
|
||||
|
||||
commits = [ ]
|
||||
|
||||
for line in filp:
|
||||
|
||||
line = line.strip()
|
||||
|
||||
# Skip empty lines and lines that start with a '#'.
|
||||
if line.find('#') == 0 or line == '':
|
||||
continue
|
||||
|
||||
# Otherwise append the line to the list of commits. This will append
|
||||
# all the text, so in cases like:
|
||||
#
|
||||
# http://git-master/r/1540705 - my commit
|
||||
#
|
||||
# Anything after the first space in the line is ignored. This lets you
|
||||
# add some descriptive text after the commit.
|
||||
commits.append(line.split()[0])
|
||||
|
||||
return commits
|
||||
|
||||
def gerrit_query(change):
|
||||
"""
|
||||
Query gerrit for the JSON change information. Return a python object
|
||||
@@ -303,6 +331,19 @@ def main():
|
||||
print('Version: %s' % VERSION)
|
||||
exit(0)
|
||||
|
||||
if arg_parser.file:
|
||||
filp = open(arg_parser.file, 'r')
|
||||
|
||||
if arg_parser.commits:
|
||||
arg_parser.commits.extend(read_commit_file(filp))
|
||||
else:
|
||||
arg_parser.commits = read_commit_file(filp)
|
||||
|
||||
# Oops: no commits?
|
||||
if not arg_parser.commits or len(arg_parser.commits) == 0:
|
||||
print 'No commits!'
|
||||
exit(-1)
|
||||
|
||||
# Builds a dictionary of Gerrit Change-Ids. From the Change-Ids we can then
|
||||
# get the commit message and URL.
|
||||
#
|
||||
@@ -310,6 +351,7 @@ def main():
|
||||
# of the commits so that the user can choose the order of the patches based
|
||||
# on the order in which they pass the commits.
|
||||
for cmt in arg_parser.commits:
|
||||
|
||||
if cmt[0] == 'I':
|
||||
info = commit_info_from_gerrit_change_id(cmt)
|
||||
elif get_gerrit_url_id(cmt):
|
||||
|
||||
Reference in New Issue
Block a user