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

Unified Diff: scm.py

Issue 10826035: Fix error syncing to LKGR due to misparsing of Cygwin git-svn output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Adding test for git-svn SHA1 output parsing Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | tests/scm_unittest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index aade53e477d78e60d2bcd7ef1d2232e61c348f75..e99acc061a2f7957b06d26b047872e5dc832d7e1 100644
--- a/scm.py
+++ b/scm.py
@@ -391,14 +391,19 @@ class GIT(object):
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
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | tests/scm_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698