OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 lastchange.py -- Chromium revision fetching utility. | 7 lastchange.py -- Chromium revision fetching utility. |
8 """ | 8 """ |
9 | 9 |
10 import re | 10 import re |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if not hsh: | 108 if not hsh: |
109 return None | 109 return None |
110 pos = '' | 110 pos = '' |
111 proc = RunGitCommand(directory, ['cat-file', 'commit', 'HEAD']) | 111 proc = RunGitCommand(directory, ['cat-file', 'commit', 'HEAD']) |
112 if proc: | 112 if proc: |
113 output = proc.communicate()[0] | 113 output = proc.communicate()[0] |
114 if proc.returncode == 0 and output: | 114 if proc.returncode == 0 and output: |
115 for line in reversed(output.splitlines()): | 115 for line in reversed(output.splitlines()): |
116 if line.startswith('Cr-Commit-Position:'): | 116 if line.startswith('Cr-Commit-Position:'): |
117 pos = line.rsplit()[-1].strip() | 117 pos = line.rsplit()[-1].strip() |
| 118 break |
118 if not pos: | 119 if not pos: |
119 return VersionInfo('git', hsh) | 120 return VersionInfo('git', hsh) |
120 return VersionInfo('git', '%s-%s' % (hsh, pos)) | 121 return VersionInfo('git', '%s-%s' % (hsh, pos)) |
121 | 122 |
122 | 123 |
123 def FetchGitSVNURLAndRevision(directory, svn_url_regex): | 124 def FetchGitSVNURLAndRevision(directory, svn_url_regex): |
124 """ | 125 """ |
125 Fetch the Subversion URL and revision through Git. | 126 Fetch the Subversion URL and revision through Git. |
126 | 127 |
127 Errors are swallowed. | 128 Errors are swallowed. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if header: | 291 if header: |
291 WriteIfChanged(header, | 292 WriteIfChanged(header, |
292 GetHeaderContents(header, opts.version_macro, | 293 GetHeaderContents(header, opts.version_macro, |
293 version_info.revision)) | 294 version_info.revision)) |
294 | 295 |
295 return 0 | 296 return 0 |
296 | 297 |
297 | 298 |
298 if __name__ == '__main__': | 299 if __name__ == '__main__': |
299 sys.exit(main()) | 300 sys.exit(main()) |
OLD | NEW |