OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 """Usage: %prog <commit>* | 5 """Usage: %prog <commit>* |
6 | 6 |
7 Given a commit, finds the release where it first appeared (e.g. 47.0.2500.0) as | 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. | 8 well as attempting to determine the branches to which it was merged. |
9 | 9 |
10 Note that it uses the "cherry picked from" annotation to find merges, so it will | 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. | 11 only work on merges that followed the "use cherry-pick -x" instructions. |
12 """ | 12 """ |
13 | 13 |
14 import optparse | 14 import optparse |
15 import re | 15 import re |
16 import sys | 16 import sys |
17 | 17 |
18 import git_common as git | 18 import git_common as git |
19 | 19 |
20 | 20 |
21 def GetNameForCommit(sha1): | 21 def GetNameForCommit(sha1): |
22 return re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1)) | 22 name = re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1)) |
| 23 if name == 'undefined': |
| 24 name = git.run( |
| 25 'name-rev', '--refs', 'remotes/branch-heads/*', '--name-only', |
| 26 sha1) + ' [untagged]' |
| 27 return name |
23 | 28 |
24 | 29 |
25 def GetMergesForCommit(sha1): | 30 def GetMergesForCommit(sha1): |
26 return [c.split()[0] for c in | 31 return [c.split()[0] for c in |
27 git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep', | 32 git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep', |
28 'cherry picked from commit %s' % sha1).splitlines()] | 33 'cherry picked from commit %s' % sha1).splitlines()] |
29 | 34 |
30 | 35 |
31 def main(): | 36 def main(): |
32 parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__) | 37 parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__) |
(...skipping 18 matching lines...) Expand all Loading... |
51 | 56 |
52 return 0 | 57 return 0 |
53 | 58 |
54 | 59 |
55 if __name__ == '__main__': | 60 if __name__ == '__main__': |
56 try: | 61 try: |
57 sys.exit(main()) | 62 sys.exit(main()) |
58 except KeyboardInterrupt: | 63 except KeyboardInterrupt: |
59 sys.stderr.write('interrupted\n') | 64 sys.stderr.write('interrupted\n') |
60 sys.exit(1) | 65 sys.exit(1) |
OLD | NEW |