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

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..f8fe68cf100b3da76a90a507dfe75de028e7272e 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -366,7 +366,18 @@ def GetSVNRevision():
if revision:
return revision
- # maybe the builder is using git-svn, try that
+ # 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.
+ p = subprocess.Popen(['git', 'log', '-100'], stdout = subprocess.PIPE,
+ stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR)
+ output, _ = p.communicate()
+ revision = ParseGitInfoOutput(output)
+ if revision:
+ return revision
+
+ # In the rare off-chance that git log -100 doesn't have a svn repo number,
+ # attempt to use "git svn info."
p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE,
stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR)
output, _ = p.communicate()
@@ -381,6 +392,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