 Chromium Code Reviews
 Chromium Code Reviews Issue 1153033007:
  Add python based VERSION file generation for sdk bots  (Closed) 
  Base URL: git@github.com:dart-lang/sdk.git@master
    
  
    Issue 1153033007:
  Add python based VERSION file generation for sdk bots  (Closed) 
  Base URL: git@github.com:dart-lang/sdk.git@master| Index: tools/utils.py | 
| diff --git a/tools/utils.py b/tools/utils.py | 
| index 2189dbae60068a7dd88cbbf3e16ef0e7a85ad1cb..a2b0e492f62a9f41d26e8f78e2b24dd762355690 100644 | 
| --- a/tools/utils.py | 
| +++ b/tools/utils.py | 
| @@ -6,6 +6,8 @@ | 
| # scripts. | 
| import commands | 
| +import datetime | 
| +import json | 
| import os | 
| import platform | 
| import re | 
| @@ -318,6 +320,21 @@ def GetEclipseVersionQualifier(): | 
| def GetVersion(): | 
| return GetSemanticSDKVersion() | 
| + | 
| +# The editor used to procude the VERSION file. We now produce this | 
| 
Bill Hesse
2015/05/28 09:18:52
produce
 
ricow1
2015/05/28 09:20:06
Done.
 | 
| +# in the bots archiving the sdk. | 
| +# The content looks like this: | 
| +#{ | 
| +# "date": "2015-05-28", | 
| +# "version": "1.11.0-edge.131653", | 
| +# "revision": "535394c2657ede445142d8a92486d3899bbf49b5" | 
| +#} | 
| +def GetVersionFileContent(): | 
| + result = {"date": str(datetime.date.today()), | 
| + "version": GetVersion(), | 
| + "revision": GetGitRevision()} | 
| + return json.dumps(result, indent=2) | 
| + | 
| def GetChannel(): | 
| version = ReadVersionFile() | 
| return version.channel | 
| @@ -388,6 +405,19 @@ def GetArchiveVersion(): | 
| return GetGitNumber() | 
| return GetSemanticSDKVersion() | 
| + | 
| +def GetGitRevision(): | 
| + p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%H'], | 
| + stdout = subprocess.PIPE, | 
| + stderr = subprocess.STDOUT, shell=IsWindows(), | 
| + cwd = DART_DIR) | 
| + output, _ = p.communicate() | 
| + # We expect a full git hash | 
| + if len(output) != 40: | 
| + print "Warning: could not parse git commit, output was %s" % output | 
| + return None | 
| + return output | 
| + | 
| # To eliminate clashing with older archived builds on bleding edge we add | 
| # a base number bigger the largest svn revision (this also gives us an easy | 
| # way of seeing if an archive comes from git based or svn based commits). | 
| @@ -507,7 +537,8 @@ def Main(): | 
| print "GuessCpus() -> ", GuessCpus() | 
| print "IsWindows() -> ", IsWindows() | 
| print "GuessVisualStudioPath() -> ", GuessVisualStudioPath() | 
| - | 
| + print "GetGitRevision() -> ", GetGitRevision() | 
| + print "GetVersionFileContent() -> ", GetVersionFileContent() | 
| class Error(Exception): | 
| pass |