OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Small utility library of python functions used during SDK building. | 5 """Small utility library of python functions used during SDK building. |
6 """ | 6 """ |
7 | 7 |
8 import os | 8 import os |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 11 matching lines...) Expand all Loading... |
22 VERSION_PATH = os.path.join(SRC_DIR, 'chrome', 'VERSION') | 22 VERSION_PATH = os.path.join(SRC_DIR, 'chrome', 'VERSION') |
23 | 23 |
24 | 24 |
25 def ChromeVersion(): | 25 def ChromeVersion(): |
26 '''Extract chrome version from src/chrome/VERSION + svn. | 26 '''Extract chrome version from src/chrome/VERSION + svn. |
27 | 27 |
28 Returns: | 28 Returns: |
29 Chrome version string or trunk + svn rev. | 29 Chrome version string or trunk + svn rev. |
30 ''' | 30 ''' |
31 info = FetchVersionInfo() | 31 info = FetchVersionInfo() |
32 if info.url.startswith('/trunk/'): | 32 if info.url == 'refs/heads/master': |
33 return 'trunk.%s' % info.revision | 33 return 'trunk.%s' % info.revision |
34 else: | 34 else: |
35 return ChromeVersionNoTrunk() | 35 return ChromeVersionNoTrunk() |
36 | 36 |
37 | 37 |
38 def ChromeVersionNoTrunk(): | 38 def ChromeVersionNoTrunk(): |
39 '''Extract the chrome version from src/chrome/VERSION. | 39 '''Extract the chrome version from src/chrome/VERSION. |
40 Ignore whether this is a trunk build. | 40 Ignore whether this is a trunk build. |
41 | 41 |
42 Returns: | 42 Returns: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 """ | 103 """ |
104 Return the "commit-position" of the Chromium git repo. This should be | 104 Return the "commit-position" of the Chromium git repo. This should be |
105 equivalent to the SVN revision if one eixsts. | 105 equivalent to the SVN revision if one eixsts. |
106 | 106 |
107 This is a copy of the (recently reverted) change in lastchange.py. | 107 This is a copy of the (recently reverted) change in lastchange.py. |
108 TODO(binji): Move this logic to lastchange.py when the dust settles. | 108 TODO(binji): Move this logic to lastchange.py when the dust settles. |
109 (see crbug.com/406783) | 109 (see crbug.com/406783) |
110 """ | 110 """ |
111 proc = lastchange.RunGitCommand(directory, | 111 proc = lastchange.RunGitCommand(directory, |
112 ['show', '-s', '--format=%B', 'HEAD']) | 112 ['show', '-s', '--format=%B', 'HEAD']) |
113 pos = '' | |
114 if proc: | 113 if proc: |
115 output = proc.communicate()[0] | 114 output = proc.communicate()[0] |
116 if proc.returncode == 0 and output: | 115 if proc.returncode == 0 and output: |
117 for line in reversed(output.splitlines()): | 116 for line in reversed(output.splitlines()): |
118 match = re.search('Cr-Commit-Position: .*@{#(\d+)}', line) | 117 match = re.search('Cr-Commit-Position: (.*)@{#(\d+)}', line) |
119 if match: | 118 if match: |
120 pos = match.group(1) | 119 return lastchange.VersionInfo(match.group(1), match.group(2)) |
121 if not pos: | 120 return lastchange.VersionInfo(None, None) |
122 return lastchange.VersionInfo(None, None) | |
123 return lastchange.VersionInfo('git', pos) | |
OLD | NEW |