Fix error syncing to LKGR due to misparsing of Cygwin git-svn output.
BUG=138104
TEST=
Review URL: https://chromiumcodereview.appspot.com/10826035
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@150952 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/scm.py b/scm.py
index aade53e..e99acc0 100644
--- a/scm.py
+++ b/scm.py
@@ -391,14 +391,19 @@
return None
@staticmethod
+ def ParseGitSvnSha1(output):
+ """Parses git-svn output for the first sha1."""
+ match = re.search(r'[0-9a-fA-F]{40}', output)
+ return match.group(0) if match else None
+
+ @staticmethod
def GetSha1ForSvnRev(cwd, rev):
"""Returns a corresponding git sha1 for a SVN revision."""
if not GIT.IsGitSvn(cwd=cwd):
return None
try:
- lines = GIT.Capture(
- ['svn', 'find-rev', 'r' + str(rev)], cwd=cwd).splitlines()
- return lines[-1].strip() if lines else None
+ output = GIT.Capture(['svn', 'find-rev', 'r' + str(rev)], cwd=cwd)
+ return GIT.ParseGitSvnSha1(output)
except subprocess2.CalledProcessError:
return None