Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: git_cl.py

Issue 1142283002: Make 'git cl status' report the current branch even if there's no active CL. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 else: 780 else:
781 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) 781 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch))
782 return self._remote 782 return self._remote
783 783
784 def GitSanityChecks(self, upstream_git_obj): 784 def GitSanityChecks(self, upstream_git_obj):
785 """Checks git repo status and ensures diff is from local commits.""" 785 """Checks git repo status and ensures diff is from local commits."""
786 786
787 if upstream_git_obj is None: 787 if upstream_git_obj is None:
788 if self.GetBranch() is None: 788 if self.GetBranch() is None:
789 print >> sys.stderr, ( 789 print >> sys.stderr, (
790 'ERROR: unable to dertermine current branch (detached HEAD?)') 790 'ERROR: unable to determine current branch (detached HEAD?)')
791 else: 791 else:
792 print >> sys.stderr, ( 792 print >> sys.stderr, (
793 'ERROR: no upstream branch') 793 'ERROR: no upstream branch')
794 return False 794 return False
795 795
796 # Verify the commit we're diffing against is in our current branch. 796 # Verify the commit we're diffing against is in our current branch.
797 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() 797 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip()
798 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() 798 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip()
799 if upstream_sha != common_ancestor: 799 if upstream_sha != common_ancestor:
800 print >> sys.stderr, ( 800 print >> sys.stderr, (
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 color = '' 1690 color = ''
1691 reset = '' 1691 reset = ''
1692 status_str = '(%s)' % status if status else '' 1692 status_str = '(%s)' % status if status else ''
1693 print ' %*s : %s%s %s%s' % ( 1693 print ' %*s : %s%s %s%s' % (
1694 alignment, ShortBranchName(branch), color, issue_url, status_str, 1694 alignment, ShortBranchName(branch), color, issue_url, status_str,
1695 reset) 1695 reset)
1696 1696
1697 cl = Changelist(auth_config=auth_config) 1697 cl = Changelist(auth_config=auth_config)
1698 print 1698 print
1699 print 'Current branch:', 1699 print 'Current branch:',
1700 print cl.GetBranch()
1700 if not cl.GetIssue(): 1701 if not cl.GetIssue():
1701 print 'no issue assigned.' 1702 print 'No issue assigned.'
1702 return 0 1703 return 0
1703 print cl.GetBranch()
1704 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) 1704 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
1705 if not options.fast: 1705 if not options.fast:
1706 print 'Issue description:' 1706 print 'Issue description:'
1707 print cl.GetDescription(pretty=True) 1707 print cl.GetDescription(pretty=True)
1708 return 0 1708 return 0
1709 1709
1710 1710
1711 def colorize_CMDstatus_doc(): 1711 def colorize_CMDstatus_doc():
1712 """To be called once in main() to add colors to git cl status help.""" 1712 """To be called once in main() to add colors to git cl status help."""
1713 colors = [i for i in dir(Fore) if i[0].isupper()] 1713 colors = [i for i in dir(Fore) if i[0].isupper()]
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 if __name__ == '__main__': 3532 if __name__ == '__main__':
3533 # These affect sys.stdout so do it outside of main() to simplify mocks in 3533 # These affect sys.stdout so do it outside of main() to simplify mocks in
3534 # unit testing. 3534 # unit testing.
3535 fix_encoding.fix_encoding() 3535 fix_encoding.fix_encoding()
3536 colorama.init() 3536 colorama.init()
3537 try: 3537 try:
3538 sys.exit(main(sys.argv[1:])) 3538 sys.exit(main(sys.argv[1:]))
3539 except KeyboardInterrupt: 3539 except KeyboardInterrupt:
3540 sys.stderr.write('interrupted\n') 3540 sys.stderr.write('interrupted\n')
3541 sys.exit(1) 3541 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698