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 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 self.SetPatchset(patchset) | 1859 self.SetPatchset(patchset) |
1860 print('Committed patch locally.') | 1860 print('Committed patch locally.') |
1861 else: | 1861 else: |
1862 print('Patch applied to index.') | 1862 print('Patch applied to index.') |
1863 return 0 | 1863 return 0 |
1864 | 1864 |
1865 @staticmethod | 1865 @staticmethod |
1866 def ParseIssueURL(parsed_url): | 1866 def ParseIssueURL(parsed_url): |
1867 if not parsed_url.scheme or not parsed_url.scheme.startswith('http'): | 1867 if not parsed_url.scheme or not parsed_url.scheme.startswith('http'): |
1868 return None | 1868 return None |
| 1869 # Rietveld patch: https://domain/<number>/#ps<patchset> |
| 1870 match = re.match(r'/(\d+)/$', parsed_url.path) |
| 1871 match2 = re.match(r'ps(\d+)$', parsed_url.fragment) |
| 1872 if match and match2: |
| 1873 return _RietveldParsedIssueNumberArgument( |
| 1874 issue=int(match.group(1)), |
| 1875 patchset=int(match2.group(1)), |
| 1876 hostname=parsed_url.netloc) |
1869 # Typical url: https://domain/<issue_number>[/[other]] | 1877 # Typical url: https://domain/<issue_number>[/[other]] |
1870 match = re.match('/(\d+)(/.*)?$', parsed_url.path) | 1878 match = re.match('/(\d+)(/.*)?$', parsed_url.path) |
1871 if match: | 1879 if match: |
1872 return _RietveldParsedIssueNumberArgument( | 1880 return _RietveldParsedIssueNumberArgument( |
1873 issue=int(match.group(1)), | 1881 issue=int(match.group(1)), |
1874 hostname=parsed_url.netloc) | 1882 hostname=parsed_url.netloc) |
1875 # Rietveld patch: https://domain/download/issue<number>_<patchset>.diff | 1883 # Rietveld patch: https://domain/download/issue<number>_<patchset>.diff |
1876 match = re.match(r'/download/issue(\d+)_(\d+).diff$', parsed_url.path) | 1884 match = re.match(r'/download/issue(\d+)_(\d+).diff$', parsed_url.path) |
1877 if match: | 1885 if match: |
1878 return _RietveldParsedIssueNumberArgument( | 1886 return _RietveldParsedIssueNumberArgument( |
(...skipping 3208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5087 if __name__ == '__main__': | 5095 if __name__ == '__main__': |
5088 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5096 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5089 # unit testing. | 5097 # unit testing. |
5090 fix_encoding.fix_encoding() | 5098 fix_encoding.fix_encoding() |
5091 setup_color.init() | 5099 setup_color.init() |
5092 try: | 5100 try: |
5093 sys.exit(main(sys.argv[1:])) | 5101 sys.exit(main(sys.argv[1:])) |
5094 except KeyboardInterrupt: | 5102 except KeyboardInterrupt: |
5095 sys.stderr.write('interrupted\n') | 5103 sys.stderr.write('interrupted\n') |
5096 sys.exit(1) | 5104 sys.exit(1) |
OLD | NEW |