summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2017-10-25 08:16:09 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-11-01 03:05:14 -0400
commitb5b9e71bd50844287dfc38acfa1acf4249c11371 (patch)
tree0f322500eed81cc61b9d238c3cd060e1891644ad /scripts
parent8221a19e13eb388b2fca46ac02cf3f1b5b0b8b7a (diff)
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 <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1585436 Reviewed-by: Alex Waterman <alexw@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/rfr32
1 files 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):
113 113
114 return gerrit_query(change_id) 114 return gerrit_query(change_id)
115 115
116def gerrit_change_id_from_gerrit_cl(cmt): 116def commit_info_from_gerrit_cl(cmt):
117 """ 117 """
118 Return the gerrit Change-Id from the passed Gerrit URL. 118 Return a dict with all the gerrit info from a Gerrit URL.
119 """ 119 """
120 120
121 cl = get_gerrit_url_id(cmt) 121 cl = get_gerrit_url_id(cmt)
122 if not cl: 122 if not cl:
123 return None 123 return None
124 124
125 commit = gerrit_query(cl) 125 return gerrit_query(cl)
126 if not commit:
127 return None
128
129 return commit['id']
130 126
131def gerrit_change_id_from_git_commit(cmt_id): 127def gerrit_change_id_from_git_commit(cmt_id):
132 """ 128 """
@@ -157,9 +153,9 @@ def indent_lines(text, ind):
157 """ 153 """
158 return ''.join(ind + l + '\n' for l in text.splitlines()) 154 return ''.join(ind + l + '\n' for l in text.splitlines())
159 155
160def display_commits(commits, extra_message): 156def display_commits(commits_info, extra_message):
161 """ 157 """
162 Takes a list of the commits to print. 158 Takes a list of the commit info objects to print.
163 """ 159 """
164 160
165 whole_template = """ 161 whole_template = """
@@ -178,10 +174,6 @@ Thanks!
178 174
179{cmtmsg}""" 175{cmtmsg}"""
180 176
181 commits_info = [ ]
182 for cmt in commits:
183 commits_info.append(commit_info_from_gerrit_change_id(cmt))
184
185 cmt_descriptions = '' 177 cmt_descriptions = ''
186 for c in commits_info: 178 for c in commits_info:
187 cmt_descriptions += " %s - %s\n" % (c['url'], c['subject']) 179 cmt_descriptions += " %s - %s\n" % (c['url'], c['subject'])
@@ -210,7 +202,7 @@ def main():
210 """ 202 """
211 203
212 arg_parser = parse_args() 204 arg_parser = parse_args()
213 commits = [ ] 205 commits_info = [ ]
214 206
215 if arg_parser.version: 207 if arg_parser.version:
216 print('Version: %s' % VERSION) 208 print('Version: %s' % VERSION)
@@ -224,18 +216,18 @@ def main():
224 # on the order in which they pass the commits. 216 # on the order in which they pass the commits.
225 for cmt in arg_parser.commits: 217 for cmt in arg_parser.commits:
226 if cmt[0] == 'I': 218 if cmt[0] == 'I':
227 cid = cmt 219 info = commit_info_from_gerrit_change_id(cmt)
228 elif get_gerrit_url_id(cmt): 220 elif get_gerrit_url_id(cmt):
229 cid = gerrit_change_id_from_gerrit_cl(cmt) 221 info = commit_info_from_gerrit_cl(cmt)
230 else: 222 else:
231 cid = gerrit_change_id_from_git_commit(cmt) 223 info = commit_info_from_gerrit_change_id(gerrit_change_id_from_git_commit(cmt))
232 224
233 if cid: 225 if info:
234 commits.append(cid) 226 commits_info.append(info)
235 else: 227 else:
236 print('Warning: \'%s\' doesn\'t appear to be a commit!' % cmt) 228 print('Warning: \'%s\' doesn\'t appear to be a commit!' % cmt)
237 229
238 display_commits(commits, arg_parser.msg) 230 display_commits(commits_info, arg_parser.msg)
239 231
240if __name__ == '__main__': 232if __name__ == '__main__':
241 main() 233 main()