From b5b9e71bd50844287dfc38acfa1acf4249c11371 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Wed, 25 Oct 2017 15:16:09 +0300 Subject: scripts: rfr: explicitly use gerrit cl if needed Fetch the full patch information from gerrit as soon as possible, so that the gerrit cl (i.e., git-master url) is used if given, because it has more information than the change-id (which may exist in multiple branches). Querying based on change-id or git commit-id are left as-is. Change-Id: I58dfa9da7354d607ca7e38f91e4a5f2c92c8454f Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1585436 Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- scripts/rfr | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/scripts/rfr b/scripts/rfr index 723fde51..b225bc3a 100755 --- a/scripts/rfr +++ b/scripts/rfr @@ -113,20 +113,16 @@ def commit_info_from_gerrit_change_id(change_id): return gerrit_query(change_id) -def gerrit_change_id_from_gerrit_cl(cmt): +def commit_info_from_gerrit_cl(cmt): """ - Return the gerrit Change-Id from the passed Gerrit URL. + Return a dict with all the gerrit info from a Gerrit URL. """ cl = get_gerrit_url_id(cmt) if not cl: return None - commit = gerrit_query(cl) - if not commit: - return None - - return commit['id'] + return gerrit_query(cl) def gerrit_change_id_from_git_commit(cmt_id): """ @@ -157,9 +153,9 @@ def indent_lines(text, ind): """ return ''.join(ind + l + '\n' for l in text.splitlines()) -def display_commits(commits, extra_message): +def display_commits(commits_info, extra_message): """ - Takes a list of the commits to print. + Takes a list of the commit info objects to print. """ whole_template = """ @@ -178,10 +174,6 @@ Thanks! {cmtmsg}""" - commits_info = [ ] - for cmt in commits: - commits_info.append(commit_info_from_gerrit_change_id(cmt)) - cmt_descriptions = '' for c in commits_info: cmt_descriptions += " %s - %s\n" % (c['url'], c['subject']) @@ -210,7 +202,7 @@ def main(): """ arg_parser = parse_args() - commits = [ ] + commits_info = [ ] if arg_parser.version: print('Version: %s' % VERSION) @@ -224,18 +216,18 @@ def main(): # on the order in which they pass the commits. for cmt in arg_parser.commits: if cmt[0] == 'I': - cid = cmt + info = commit_info_from_gerrit_change_id(cmt) elif get_gerrit_url_id(cmt): - cid = gerrit_change_id_from_gerrit_cl(cmt) + info = commit_info_from_gerrit_cl(cmt) else: - cid = gerrit_change_id_from_git_commit(cmt) + info = commit_info_from_gerrit_change_id(gerrit_change_id_from_git_commit(cmt)) - if cid: - commits.append(cid) + if info: + commits_info.append(info) else: print('Warning: \'%s\' doesn\'t appear to be a commit!' % cmt) - display_commits(commits, arg_parser.msg) + display_commits(commits_info, arg_parser.msg) if __name__ == '__main__': main() -- cgit v1.2.2