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

Side by Side Diff: git_find_releases.py

Issue 1332473003: Add new tool, git find-releases (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: nit Created 5 years, 3 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 | « git-find-releases ('k') | 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
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 """Usage: %prog <commit>*
6
7 Given a commit, finds the release where it first appeared (e.g. 47.0.2500.0) as
8 well as attempting to determine the branches to which it was merged.
9
10 Note that it uses the "cherry picked from" annotation to find merges, so it will
11 only work on merges that followed the "use cherry-pick -x" instructions.
12 """
13
14 import optparse
15 import re
16 import sys
17
18 import git_common as git
19
20
21 def GetNameForCommit(sha1):
22 return re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1))
23
24
25 def GetMergesForCommit(sha1):
26 return [c.split()[0] for c in
27 git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep',
28 'cherry picked from commit %s' % sha1).splitlines()]
29
30
31 def main():
32 parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
33 _, args = parser.parse_args()
34
35 if len(args) == 0:
36 parser.error('Need at least one commit.')
37
38 for arg in args:
39 commit_name = GetNameForCommit(arg)
40 if not commit_name:
41 print '%s not found' % arg
42 return 1
43 print 'commit %s was:' % arg
44 print ' initially in ' + commit_name
45 merges = GetMergesForCommit(arg)
46 for merge in merges:
47 print ' merged to ' + GetNameForCommit(merge) + ' (as ' + merge + ')'
48 if not merges:
49 print 'No merges found. If this seems wrong, be sure that you did:'
50 print ' git fetch origin && gclient sync --with_branch_heads'
51
52 return 0
53
54
55 if __name__ == '__main__':
56 try:
57 sys.exit(main())
58 except KeyboardInterrupt:
59 sys.stderr.write('interrupted\n')
60 sys.exit(1)
OLDNEW
« no previous file with comments | « git-find-releases ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698