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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git-find-releases ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_find_releases.py
diff --git a/git_find_releases.py b/git_find_releases.py
new file mode 100755
index 0000000000000000000000000000000000000000..76e114eedd9a5bc1ce0ba3c8266945110a802680
--- /dev/null
+++ b/git_find_releases.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Usage: %prog <commit>*
+
+Given a commit, finds the release where it first appeared (e.g. 47.0.2500.0) as
+well as attempting to determine the branches to which it was merged.
+
+Note that it uses the "cherry picked from" annotation to find merges, so it will
+only work on merges that followed the "use cherry-pick -x" instructions.
+"""
+
+import optparse
+import re
+import sys
+
+import git_common as git
+
+
+def GetNameForCommit(sha1):
+ return re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1))
+
+
+def GetMergesForCommit(sha1):
+ return [c.split()[0] for c in
+ git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep',
+ 'cherry picked from commit %s' % sha1).splitlines()]
+
+
+def main():
+ parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
+ _, args = parser.parse_args()
+
+ if len(args) == 0:
+ parser.error('Need at least one commit.')
+
+ for arg in args:
+ commit_name = GetNameForCommit(arg)
+ if not commit_name:
+ print '%s not found' % arg
+ return 1
+ print 'commit %s was:' % arg
+ print ' initially in ' + commit_name
+ merges = GetMergesForCommit(arg)
+ for merge in merges:
+ print ' merged to ' + GetNameForCommit(merge) + ' (as ' + merge + ')'
+ if not merges:
+ print 'No merges found. If this seems wrong, be sure that you did:'
+ print ' git fetch origin && gclient sync --with_branch_heads'
+
+ return 0
+
+
+if __name__ == '__main__':
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ sys.stderr.write('interrupted\n')
+ sys.exit(1)
« 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