OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 def _GetChangeDetail(self, options=None, issue=None): | 2530 def _GetChangeDetail(self, options=None, issue=None): |
2531 options = options or [] | 2531 options = options or [] |
2532 issue = issue or self.GetIssue() | 2532 issue = issue or self.GetIssue() |
2533 assert issue, 'issue is required to query Gerrit' | 2533 assert issue, 'issue is required to query Gerrit' |
2534 data = gerrit_util.GetChangeDetail(self._GetGerritHost(), str(issue), | 2534 data = gerrit_util.GetChangeDetail(self._GetGerritHost(), str(issue), |
2535 options) | 2535 options) |
2536 if not data: | 2536 if not data: |
2537 raise GerritIssueNotExists(issue, self.GetCodereviewServer()) | 2537 raise GerritIssueNotExists(issue, self.GetCodereviewServer()) |
2538 return data | 2538 return data |
2539 | 2539 |
| 2540 def _GetChangeCommit(self, issue=None): |
| 2541 issue = issue or self.GetIssue() |
| 2542 assert issue, 'issue is required to query Gerrit' |
| 2543 data = gerrit_util.GetChangeCommit(self._GetGerritHost(), str(issue)) |
| 2544 if not data: |
| 2545 raise GerritIssueNotExists(issue, self.GetCodereviewServer()) |
| 2546 return data |
| 2547 |
2540 def CMDLand(self, force, bypass_hooks, verbose): | 2548 def CMDLand(self, force, bypass_hooks, verbose): |
2541 if git_common.is_dirty_git_tree('land'): | 2549 if git_common.is_dirty_git_tree('land'): |
2542 return 1 | 2550 return 1 |
2543 detail = self._GetChangeDetail(['CURRENT_REVISION', 'LABELS']) | 2551 detail = self._GetChangeDetail(['CURRENT_REVISION', 'LABELS']) |
2544 if u'Commit-Queue' in detail.get('labels', {}): | 2552 if u'Commit-Queue' in detail.get('labels', {}): |
2545 if not force: | 2553 if not force: |
2546 ask_for_data('\nIt seems this repository has a Commit Queue, ' | 2554 ask_for_data('\nIt seems this repository has a Commit Queue, ' |
2547 'which can test and land changes for you. ' | 2555 'which can test and land changes for you. ' |
2548 'Are you sure you wish to bypass it?\n' | 2556 'Are you sure you wish to bypass it?\n' |
2549 'Press Enter to continue, Ctrl+C to abort.') | 2557 'Press Enter to continue, Ctrl+C to abort.') |
(...skipping 18 matching lines...) Expand all Loading... |
2568 hook_results = self.RunHook( | 2576 hook_results = self.RunHook( |
2569 committing=True, | 2577 committing=True, |
2570 may_prompt=not force, | 2578 may_prompt=not force, |
2571 verbose=verbose, | 2579 verbose=verbose, |
2572 change=self.GetChange(self.GetCommonAncestorWithUpstream(), None)) | 2580 change=self.GetChange(self.GetCommonAncestorWithUpstream(), None)) |
2573 if not hook_results.should_continue(): | 2581 if not hook_results.should_continue(): |
2574 return 1 | 2582 return 1 |
2575 | 2583 |
2576 self.SubmitIssue(wait_for_merge=True) | 2584 self.SubmitIssue(wait_for_merge=True) |
2577 print('Issue %s has been submitted.' % self.GetIssueURL()) | 2585 print('Issue %s has been submitted.' % self.GetIssueURL()) |
| 2586 links = self._GetChangeCommit().get('web_links', []) |
| 2587 for link in links: |
| 2588 if link.get('name') == 'gerrit' and link.get('url'): |
| 2589 print('Landed as %s' % link.get('url')) |
| 2590 break |
2578 return 0 | 2591 return 0 |
2579 | 2592 |
2580 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit, | 2593 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit, |
2581 directory): | 2594 directory): |
2582 assert not reject | 2595 assert not reject |
2583 assert not nocommit | 2596 assert not nocommit |
2584 assert not directory | 2597 assert not directory |
2585 assert parsed_issue_arg.valid | 2598 assert parsed_issue_arg.valid |
2586 | 2599 |
2587 self._changelist.issue = parsed_issue_arg.issue | 2600 self._changelist.issue = parsed_issue_arg.issue |
(...skipping 2807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5395 if __name__ == '__main__': | 5408 if __name__ == '__main__': |
5396 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5409 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5397 # unit testing. | 5410 # unit testing. |
5398 fix_encoding.fix_encoding() | 5411 fix_encoding.fix_encoding() |
5399 setup_color.init() | 5412 setup_color.init() |
5400 try: | 5413 try: |
5401 sys.exit(main(sys.argv[1:])) | 5414 sys.exit(main(sys.argv[1:])) |
5402 except KeyboardInterrupt: | 5415 except KeyboardInterrupt: |
5403 sys.stderr.write('interrupted\n') | 5416 sys.stderr.write('interrupted\n') |
5404 sys.exit(1) | 5417 sys.exit(1) |
OLD | NEW |