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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 else: | 788 else: |
789 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) | 789 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) |
790 return self._remote | 790 return self._remote |
791 | 791 |
792 def GitSanityChecks(self, upstream_git_obj): | 792 def GitSanityChecks(self, upstream_git_obj): |
793 """Checks git repo status and ensures diff is from local commits.""" | 793 """Checks git repo status and ensures diff is from local commits.""" |
794 | 794 |
795 if upstream_git_obj is None: | 795 if upstream_git_obj is None: |
796 if self.GetBranch() is None: | 796 if self.GetBranch() is None: |
797 print >> sys.stderr, ( | 797 print >> sys.stderr, ( |
798 'ERROR: unable to dertermine current branch (detached HEAD?)') | 798 'ERROR: unable to determine current branch (detached HEAD?)') |
799 else: | 799 else: |
800 print >> sys.stderr, ( | 800 print >> sys.stderr, ( |
801 'ERROR: no upstream branch') | 801 'ERROR: no upstream branch') |
802 return False | 802 return False |
803 | 803 |
804 # Verify the commit we're diffing against is in our current branch. | 804 # Verify the commit we're diffing against is in our current branch. |
805 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() | 805 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() |
806 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() | 806 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() |
807 if upstream_sha != common_ancestor: | 807 if upstream_sha != common_ancestor: |
808 print >> sys.stderr, ( | 808 print >> sys.stderr, ( |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 color = '' | 1698 color = '' |
1699 reset = '' | 1699 reset = '' |
1700 status_str = '(%s)' % status if status else '' | 1700 status_str = '(%s)' % status if status else '' |
1701 print ' %*s : %s%s %s%s' % ( | 1701 print ' %*s : %s%s %s%s' % ( |
1702 alignment, ShortBranchName(branch), color, issue_url, status_str, | 1702 alignment, ShortBranchName(branch), color, issue_url, status_str, |
1703 reset) | 1703 reset) |
1704 | 1704 |
1705 cl = Changelist(auth_config=auth_config) | 1705 cl = Changelist(auth_config=auth_config) |
1706 print | 1706 print |
1707 print 'Current branch:', | 1707 print 'Current branch:', |
| 1708 print cl.GetBranch() |
1708 if not cl.GetIssue(): | 1709 if not cl.GetIssue(): |
1709 print 'no issue assigned.' | 1710 print 'No issue assigned.' |
1710 return 0 | 1711 return 0 |
1711 print cl.GetBranch() | |
1712 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) | 1712 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) |
1713 if not options.fast: | 1713 if not options.fast: |
1714 print 'Issue description:' | 1714 print 'Issue description:' |
1715 print cl.GetDescription(pretty=True) | 1715 print cl.GetDescription(pretty=True) |
1716 return 0 | 1716 return 0 |
1717 | 1717 |
1718 | 1718 |
1719 def colorize_CMDstatus_doc(): | 1719 def colorize_CMDstatus_doc(): |
1720 """To be called once in main() to add colors to git cl status help.""" | 1720 """To be called once in main() to add colors to git cl status help.""" |
1721 colors = [i for i in dir(Fore) if i[0].isupper()] | 1721 colors = [i for i in dir(Fore) if i[0].isupper()] |
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3558 if __name__ == '__main__': | 3558 if __name__ == '__main__': |
3559 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3559 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3560 # unit testing. | 3560 # unit testing. |
3561 fix_encoding.fix_encoding() | 3561 fix_encoding.fix_encoding() |
3562 colorama.init() | 3562 colorama.init() |
3563 try: | 3563 try: |
3564 sys.exit(main(sys.argv[1:])) | 3564 sys.exit(main(sys.argv[1:])) |
3565 except KeyboardInterrupt: | 3565 except KeyboardInterrupt: |
3566 sys.stderr.write('interrupted\n') | 3566 sys.stderr.write('interrupted\n') |
3567 sys.exit(1) | 3567 sys.exit(1) |
OLD | NEW |