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

Side by Side Diff: build/util/lastchange.py

Issue 488733002: Get lastchange.py to work correctly on Git repositories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 Errors are swallowed. 97 Errors are swallowed.
98 98
99 Returns: 99 Returns:
100 A VersionInfo object or None on error. 100 A VersionInfo object or None on error.
101 """ 101 """
102 proc = RunGitCommand(directory, ['rev-parse', 'HEAD']) 102 proc = RunGitCommand(directory, ['rev-parse', 'HEAD'])
103 if proc: 103 if proc:
104 output = proc.communicate()[0].strip() 104 output = proc.communicate()[0].strip()
105 if proc.returncode == 0 and output: 105 if proc.returncode == 0 and output:
106 return VersionInfo('git', output[:7]) 106 return VersionInfo('git', output)
iannucci 2014/08/19 18:49:46 should we include the commit position here, if it'
agable 2014/08/19 22:00:30 The output cannot be multiline. It's unclear to me
107 return None 107 return None
108 108
109 109
110 def FetchGitSVNURLAndRevision(directory, svn_url_regex): 110 def FetchGitSVNURLAndRevision(directory, svn_url_regex):
111 """ 111 """
112 Fetch the Subversion URL and revision through Git. 112 Fetch the Subversion URL and revision through Git.
113 113
114 Errors are swallowed. 114 Errors are swallowed.
115 115
116 Returns: 116 Returns:
117 A tuple containing the Subversion URL and revision. 117 A tuple containing the Subversion URL and revision.
118 """ 118 """
119 proc = RunGitCommand(directory, ['log', '-1', 119 proc = RunGitCommand(directory, ['log', '-1', '--format=%b'])
120 '--grep=git-svn-id', '--format=%b'])
121 if proc: 120 if proc:
122 output = proc.communicate()[0].strip() 121 output = proc.communicate()[0].strip()
123 if proc.returncode == 0 and output: 122 if proc.returncode == 0 and output:
124 # Extract the latest SVN revision and the SVN URL. 123 # Extract the latest SVN revision and the SVN URL.
125 # The target line is the last "git-svn-id: ..." line like this: 124 # The target line is the last "git-svn-id: ..." line like this:
126 # git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85528 0039d316.... 125 # git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85528 0039d316....
127 match = _GIT_SVN_ID_REGEX.search(output) 126 match = _GIT_SVN_ID_REGEX.search(output)
128 if match: 127 if match:
129 revision = match.group(2) 128 revision = match.group(2)
130 url_match = svn_url_regex.search(match.group(1)) 129 url_match = svn_url_regex.search(match.group(1))
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if header: 277 if header:
279 WriteIfChanged(header, 278 WriteIfChanged(header,
280 GetHeaderContents(header, opts.version_macro, 279 GetHeaderContents(header, opts.version_macro,
281 version_info.revision)) 280 version_info.revision))
282 281
283 return 0 282 return 0
284 283
285 284
286 if __name__ == '__main__': 285 if __name__ == '__main__':
287 sys.exit(main()) 286 sys.exit(main())
OLDNEW
« 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