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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 import owners_finder | 57 import owners_finder |
58 import presubmit_support | 58 import presubmit_support |
59 import rietveld | 59 import rietveld |
60 import scm | 60 import scm |
61 import subcommand | 61 import subcommand |
62 import subprocess2 | 62 import subprocess2 |
63 import watchlists | 63 import watchlists |
64 | 64 |
65 __version__ = '2.0' | 65 __version__ = '2.0' |
66 | 66 |
| 67 COMMIT_BOT_EMAIL = 'commit-bot@chromium.org' |
67 DEFAULT_SERVER = 'https://codereview.appspot.com' | 68 DEFAULT_SERVER = 'https://codereview.appspot.com' |
68 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' | 69 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' |
69 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' | 70 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' |
70 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' | 71 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' |
71 REFS_THAT_ALIAS_TO_OTHER_REFS = { | 72 REFS_THAT_ALIAS_TO_OTHER_REFS = { |
72 'refs/remotes/origin/lkgr': 'refs/remotes/origin/master', | 73 'refs/remotes/origin/lkgr': 'refs/remotes/origin/master', |
73 'refs/remotes/origin/lkcr': 'refs/remotes/origin/master', | 74 'refs/remotes/origin/lkcr': 'refs/remotes/origin/master', |
74 } | 75 } |
75 | 76 |
76 # Valid extensions for files we want to lint. | 77 # Valid extensions for files we want to lint. |
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 reviewers = self.GetApprovingReviewers() | 1701 reviewers = self.GetApprovingReviewers() |
1701 except urllib2.HTTPError: | 1702 except urllib2.HTTPError: |
1702 return 'error' | 1703 return 'error' |
1703 | 1704 |
1704 if reviewers: | 1705 if reviewers: |
1705 # Was LGTM'ed. | 1706 # Was LGTM'ed. |
1706 return 'lgtm' | 1707 return 'lgtm' |
1707 | 1708 |
1708 messages = props.get('messages') or [] | 1709 messages = props.get('messages') or [] |
1709 | 1710 |
| 1711 # Skip CQ messages that don't require owner's action. |
| 1712 while messages and messages[-1]['sender'] == COMMIT_BOT_EMAIL: |
| 1713 if 'Dry run:' in messages[-1]['text']: |
| 1714 messages.pop() |
| 1715 elif 'The CQ bit was unchecked' in messages[-1]['text']: |
| 1716 # This message always follows prior messages from CQ, |
| 1717 # so skip this too. |
| 1718 messages.pop() |
| 1719 else: |
| 1720 # This is probably a CQ messages warranting user attention. |
| 1721 break |
| 1722 |
1710 if not messages: | 1723 if not messages: |
1711 # No message was sent. | 1724 # No message was sent. |
1712 return 'unsent' | 1725 return 'unsent' |
1713 if messages[-1]['sender'] != props.get('owner_email'): | 1726 if messages[-1]['sender'] != props.get('owner_email'): |
1714 # Non-LGTM reply from non-owner | 1727 # Non-LGTM reply from non-owner and not CQ bot. |
1715 return 'reply' | 1728 return 'reply' |
1716 return 'waiting' | 1729 return 'waiting' |
1717 | 1730 |
1718 def UpdateDescriptionRemote(self, description): | 1731 def UpdateDescriptionRemote(self, description): |
1719 return self.RpcServer().update_description( | 1732 return self.RpcServer().update_description( |
1720 self.GetIssue(), self.description) | 1733 self.GetIssue(), self.description) |
1721 | 1734 |
1722 def CloseIssue(self): | 1735 def CloseIssue(self): |
1723 return self.RpcServer().close_issue(self.GetIssue()) | 1736 return self.RpcServer().close_issue(self.GetIssue()) |
1724 | 1737 |
(...skipping 3326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5051 if __name__ == '__main__': | 5064 if __name__ == '__main__': |
5052 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5065 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5053 # unit testing. | 5066 # unit testing. |
5054 fix_encoding.fix_encoding() | 5067 fix_encoding.fix_encoding() |
5055 setup_color.init() | 5068 setup_color.init() |
5056 try: | 5069 try: |
5057 sys.exit(main(sys.argv[1:])) | 5070 sys.exit(main(sys.argv[1:])) |
5058 except KeyboardInterrupt: | 5071 except KeyboardInterrupt: |
5059 sys.stderr.write('interrupted\n') | 5072 sys.stderr.write('interrupted\n') |
5060 sys.exit(1) | 5073 sys.exit(1) |
OLD | NEW |