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

Unified Diff: tools/utils.py

Issue 327563003: Use "git log" instead of "git svn info" for revision number information, since (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/utils.py
diff --git a/tools/utils.py b/tools/utils.py
index f4a37553c5ede21e3f24afe4e684b5ab465dea25..fc55a5b1cfd7dc8789f10310cc97e80807bf35e0 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -366,11 +366,13 @@ def GetSVNRevision():
if revision:
return revision
- # maybe the builder is using git-svn, try that
- p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE,
+ # Check for revision using git (Note: we can't use git-svn because in a
+ # pure-git checkout, "git-svn anyCommand" just hangs!). We look an arbitrary
+ # number of commits backwards (100) to get past any local commits.
ricow1 2014/06/10 10:44:10 will this actually give the correct revision?
Emily Fortuna 2014/06/10 16:08:47 Yup, as long as there are no more than 100 local c
+ p = subprocess.Popen(['git', 'log', '-100'], stdout = subprocess.PIPE,
stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR)
Emily Fortuna 2014/06/09 17:45:41 Yeah, the 100 is gross, but better than hanging in
output, _ = p.communicate()
- revision = ParseSvnInfoOutput(output)
+ revision = ParseGitInfoOutput(output)
if revision:
blois 2014/06/16 19:20:12 Could fall back to git svn info if this fails, jus
return revision
@@ -381,6 +383,14 @@ def GetSVNRevision():
return None
+def ParseGitInfoOutput(output):
+ """Given a git log, determine the latest corresponding svn revision."""
+ for line in output.split('\n'):
+ tokens = line.split()
+ if len(tokens) > 0 and tokens[0] == 'git-svn-id:':
+ return tokens[1].split('@')[1]
+ return None
+
def ParseSvnInfoOutput(output):
revision_match = re.search('Last Changed Rev: (\d+)', output)
if revision_match:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698