blob: be8083af2fe655aaea8a34d971d2fadac9709d10 [file] [log] [blame]
[email protected]cabf2ad2009-08-22 01:26:311#!/usr/bin/python
[email protected]ba551772010-02-03 18:21:422# Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]6f943c22009-09-01 00:41:143# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
[email protected]82f2c082009-12-08 21:25:375"""Wrapper for trychange.py for git checkout."""
[email protected]565db0e2009-06-05 18:08:546
[email protected]7538b862010-01-08 21:41:337import logging
[email protected]82f2c082009-12-08 21:25:378import sys
[email protected]82f2c082009-12-08 21:25:379
[email protected]cb2985f2010-11-03 14:08:3110import breakpad # pylint: disable=W0611
[email protected]82f2c082009-12-08 21:25:3711
[email protected]24b74202010-09-09 15:02:5612import gclient_utils
[email protected]e2b865c2009-12-23 16:29:3413from scm import GIT
[email protected]42c7f662010-10-06 23:52:4614import third_party.upload
[email protected]b0e621f2009-08-25 21:01:5115import trychange
[email protected]565db0e2009-06-05 18:08:5416
[email protected]cabf2ad2009-08-22 01:26:3117
[email protected]cabf2ad2009-08-22 01:26:3118def GetRietveldIssueNumber():
[email protected]24b74202010-09-09 15:02:5619 try:
20 return GIT.Capture(
21 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)])
22 except gclient_utils.Error:
23 return None
[email protected]cabf2ad2009-08-22 01:26:3124
25
26def GetRietveldPatchsetNumber():
[email protected]24b74202010-09-09 15:02:5627 try:
28 return GIT.Capture(
29 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)])
30 except gclient_utils.Error:
31 return None
[email protected]cabf2ad2009-08-22 01:26:3132
33
[email protected]c2190cb2010-01-10 01:57:0634def GetRietveldServerUrl():
[email protected]24b74202010-09-09 15:02:5635 try:
36 return GIT.Capture(['config', 'rietveld.server']).strip()
37 except gclient_utils.Error:
38 return None
[email protected]c2190cb2010-01-10 01:57:0639
40
[email protected]cabf2ad2009-08-22 01:26:3141if __name__ == '__main__':
[email protected]53ac3352010-09-15 20:46:5542 args = sys.argv[1:]
[email protected]e2b865c2009-12-23 16:29:3443 patchset = GetRietveldPatchsetNumber()
44 if patchset:
[email protected]b0e621f2009-08-25 21:01:5145 args.extend([
46 '--issue', GetRietveldIssueNumber(),
[email protected]e2b865c2009-12-23 16:29:3447 '--patchset', patchset,
[email protected]b0e621f2009-08-25 21:01:5148 ])
[email protected]c2190cb2010-01-10 01:57:0649 else:
50 rietveld_url = GetRietveldServerUrl()
51 if rietveld_url:
52 args.extend(['--rietveld_url', GetRietveldServerUrl()])
[email protected]7538b862010-01-08 21:41:3353 # Hack around a limitation in logging.
54 logging.getLogger().handlers = []
[email protected]42c7f662010-10-06 23:52:4655 try:
56 sys.exit(trychange.TryChange(
57 args, file_list=[], swallow_exception=False,
58 prog='git-try',
59 extra_epilog='\n'
60 'git-try will diff against your tracked branch and will '
61 'detect your rietveld\n'
62 'code review if you are using git-cl\n'))
63 except third_party.upload.ClientLoginError, e:
64 print('Got an exception while trying to log in to Rietveld.')
65 print(str(e))