Index: trychange.py |
diff --git a/trychange.py b/trychange.py |
index 35a57433fd16455da69fe5ee5f3f310aefa37ade..cbb99a99b00477ea49ffac6dd3d0cc3f83397622 100755 |
--- a/trychange.py |
+++ b/trychange.py |
@@ -116,6 +116,7 @@ class SVN(SCM): |
def GetBots(self): |
try: |
+ # Try to search on the subversion repository for the file. |
import gcl |
return gcl.GetCachedFile('PRESUBMIT.py', use_root=True) |
except ImportError: |
@@ -131,7 +132,7 @@ class GIT(SCM): |
def __init__(self, *args, **kwargs): |
SCM.__init__(self, *args, **kwargs) |
self.checkout_root = os.path.abspath( |
- gclient_utils.CheckCall(['git', 'rev-parse', '--show-cdup']).strip()) |
+ scm.GIT.Capture(['rev-parse', '--show-cdup']).strip()) |
if not self.options.diff: |
self.options.diff = self._GenerateDiff() |
if not self.options.name: |
@@ -145,13 +146,10 @@ class GIT(SCM): |
def _GetPatchName(self): |
"""Construct a name for this patch.""" |
- # TODO: perhaps include the hash of the current commit, to distinguish |
- # patches? |
- branch = gclient_utils.CheckCall(['git', 'symbolic-ref', 'HEAD']).strip() |
- if not branch.startswith('refs/heads/'): |
- # TODO(maruel): Find a better type. |
+ branch_ref = scm.GIT.GetBranchRef(self.checkout_root) |
+ branch = scm.GIT.ShortBranchName(branch_ref) |
+ if branch == branch_ref: |
raise NoTryServerAccess("Couldn't figure out branch name") |
- branch = branch[len('refs/heads/'):] |
return branch |
def GetLocalRoot(self): |
@@ -160,6 +158,7 @@ class GIT(SCM): |
def GetBots(self): |
try: |
+ # A git checkout is always a full checkout. |
return gclient_utils.FileRead(os.path.join(self.checkout_root, |
'PRESUBMIT.py')) |
except (IOError, OSError): |