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

Side by Side Diff: git_cl.py

Issue 130803004: Indiciate the tree status in the rietveld message when bypassing hooks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: updates Created 6 years, 11 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 | Annotate | Revision Log
« gcl.py ('K') | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | 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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 if 'closed' == status: 1743 if 'closed' == status:
1744 print('The tree is closed. Please wait for it to reopen. Use ' 1744 print('The tree is closed. Please wait for it to reopen. Use '
1745 '"git cl dcommit --bypass-hooks" to commit on a closed tree.') 1745 '"git cl dcommit --bypass-hooks" to commit on a closed tree.')
1746 return 1 1746 return 1
1747 elif 'unknown' == status: 1747 elif 'unknown' == status:
1748 print('Unable to determine tree status. Please verify manually and ' 1748 print('Unable to determine tree status. Please verify manually and '
1749 'use "git cl dcommit --bypass-hooks" to commit on a closed tree.') 1749 'use "git cl dcommit --bypass-hooks" to commit on a closed tree.')
1750 else: 1750 else:
1751 breakpad.SendStack( 1751 breakpad.SendStack(
1752 'GitClHooksBypassedCommit', 1752 'GitClHooksBypassedCommit',
1753 'Issue %s/%s bypassed hook when committing' % 1753 'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
1754 (cl.GetRietveldServer(), cl.GetIssue()), 1754 (cl.GetRietveldServer(), cl.GetIssue(), GetTreeStatus()),
1755 verbose=False) 1755 verbose=False)
1756 1756
1757 change_desc = ChangeDescription(options.message) 1757 change_desc = ChangeDescription(options.message)
1758 if not change_desc.description and cl.GetIssue(): 1758 if not change_desc.description and cl.GetIssue():
1759 change_desc = ChangeDescription(cl.GetDescription()) 1759 change_desc = ChangeDescription(cl.GetDescription())
1760 1760
1761 if not change_desc.description: 1761 if not change_desc.description:
1762 if not cl.GetIssue() and options.bypass_hooks: 1762 if not cl.GetIssue() and options.bypass_hooks:
1763 change_desc = ChangeDescription(CreateDescriptionFromLog([base_branch])) 1763 change_desc = ChangeDescription(CreateDescriptionFromLog([base_branch]))
1764 else: 1764 else:
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 change_desc.append_footer('Committed: ' + viewvc_url + revision) 1864 change_desc.append_footer('Committed: ' + viewvc_url + revision)
1865 elif revision: 1865 elif revision:
1866 change_desc.append_footer('Committed: ' + revision) 1866 change_desc.append_footer('Committed: ' + revision)
1867 print ('Closing issue ' 1867 print ('Closing issue '
1868 '(you may be prompted for your codereview password)...') 1868 '(you may be prompted for your codereview password)...')
1869 cl.UpdateDescription(change_desc.description) 1869 cl.UpdateDescription(change_desc.description)
1870 cl.CloseIssue() 1870 cl.CloseIssue()
1871 props = cl.GetIssueProperties() 1871 props = cl.GetIssueProperties()
1872 patch_num = len(props['patchsets']) 1872 patch_num = len(props['patchsets'])
1873 comment = "Committed patchset #%d manually as r%s" % (patch_num, revision) 1873 comment = "Committed patchset #%d manually as r%s" % (patch_num, revision)
1874 comment += ' (presubmit successful).' if not options.bypass_hooks else '.' 1874 if options.bypass_hooks:
1875 comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.'
1876 else:
1877 comment += ' (presubmit successful).'
1875 cl.RpcServer().add_comment(cl.GetIssue(), comment) 1878 cl.RpcServer().add_comment(cl.GetIssue(), comment)
1876 cl.SetIssue(None) 1879 cl.SetIssue(None)
1877 1880
1878 if retcode == 0: 1881 if retcode == 0:
1879 hook = POSTUPSTREAM_HOOK_PATTERN % cmd 1882 hook = POSTUPSTREAM_HOOK_PATTERN % cmd
1880 if os.path.isfile(hook): 1883 if os.path.isfile(hook):
1881 RunCommand([hook, base_branch], error_ok=True) 1884 RunCommand([hook, base_branch], error_ok=True)
1882 1885
1883 return 0 1886 return 0
1884 1887
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 # git svn dcommit. 2019 # git svn dcommit.
2017 # It's the only command that doesn't use parser at all since we just defer 2020 # It's the only command that doesn't use parser at all since we just defer
2018 # execution to git-svn. 2021 # execution to git-svn.
2019 env = os.environ.copy() 2022 env = os.environ.copy()
2020 # 'cat' is a magical git string that disables pagers on all platforms. 2023 # 'cat' is a magical git string that disables pagers on all platforms.
2021 env['GIT_PAGER'] = 'cat' 2024 env['GIT_PAGER'] = 'cat'
2022 2025
2023 return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env) 2026 return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env)
2024 2027
2025 2028
2026 def GetTreeStatus(): 2029 def GetTreeStatus(url=None):
2027 """Fetches the tree status and returns either 'open', 'closed', 2030 """Fetches the tree status and returns either 'open', 'closed',
2028 'unknown' or 'unset'.""" 2031 'unknown' or 'unset'."""
2029 url = settings.GetTreeStatusUrl(error_ok=True) 2032 url = url or settings.GetTreeStatusUrl(error_ok=True)
2030 if url: 2033 if url:
2031 status = urllib2.urlopen(url).read().lower() 2034 status = urllib2.urlopen(url).read().lower()
2032 if status.find('closed') != -1 or status == '0': 2035 if status.find('closed') != -1 or status == '0':
2033 return 'closed' 2036 return 'closed'
2034 elif status.find('open') != -1 or status == '1': 2037 elif status.find('open') != -1 or status == '1':
2035 return 'open' 2038 return 'open'
2036 return 'unknown' 2039 return 'unknown'
2037 return 'unset' 2040 return 'unset'
2038 2041
2039 2042
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2405 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2403 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2406 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2404 2407
2405 2408
2406 if __name__ == '__main__': 2409 if __name__ == '__main__':
2407 # These affect sys.stdout so do it outside of main() to simplify mocks in 2410 # These affect sys.stdout so do it outside of main() to simplify mocks in
2408 # unit testing. 2411 # unit testing.
2409 fix_encoding.fix_encoding() 2412 fix_encoding.fix_encoding()
2410 colorama.init() 2413 colorama.init()
2411 sys.exit(main(sys.argv[1:])) 2414 sys.exit(main(sys.argv[1:]))
OLDNEW
« gcl.py ('K') | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698