diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/rfr | 32 |
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 | ||
116 | def gerrit_change_id_from_gerrit_cl(cmt): | 116 | def 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 | ||
131 | def gerrit_change_id_from_git_commit(cmt_id): | 127 | def 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 | ||
160 | def display_commits(commits, extra_message): | 156 | def 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 | ||
240 | if __name__ == '__main__': | 232 | if __name__ == '__main__': |
241 | main() | 233 | main() |