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

Unified Diff: tools/release/detectReverts.py

Issue 1098123002: [release-tools] Tool to find related commits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/release/detectReverts.py
diff --git a/tools/release/detectReverts.py b/tools/release/detectReverts.py
new file mode 100755
index 0000000000000000000000000000000000000000..f29be50600e642057571a5af0d05ab09cb940d3d
--- /dev/null
+++ b/tools/release/detectReverts.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import os
+import sys
+
+from subprocess import call, Popen, PIPE
+
+def print_analysis(gitWorkingDir, hashToSearch, upperBound):
Michael Achenbach 2015/04/21 14:14:24 nit: python var names
+
+ raw_output = git_execute(gitWorkingDir, ["rev-list", hashToSearch + ".." + upperBound])
Michael Achenbach 2015/04/21 14:14:24 Suggestiong: you could use log on origin/master wi
+
+ print 'test'
+ raw_output = raw_output.strip()
+ candidate_hashes = raw_output.split("\n")
Michael Achenbach 2015/04/21 14:14:24 splitlines()
+ print "Found " + str(len(candidate_hashes)) + " candidates"
+ for candidate in candidate_hashes:
+ #git show -s --format=%B SHA1
+ current_message = git_execute(gitWorkingDir, ["show","-s", "--format=%B",candidate])
+ if ("Revert" in current_message) or ("revert" in current_message):
+ if hashToSearch in current_message:
+ print "Found revert in " + candidate
+
+ print "Finished"
+
Michael Achenbach 2015/04/21 14:14:24 nit: two empty lines between things on toplevel
+def git_execute(workingDir, commands):
Michael Achenbach 2015/04/21 14:14:24 working_dir
+ p = Popen(['git', '-C', workingDir] + commands, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ output, err = p.communicate()
+ rc = p.returncode
+ if rc != 0:
+ raise Exception(err)
+
+ return output
+
+if __name__ == "__main__": # pragma: no cover
+ parser = argparse.ArgumentParser('Tool to check where a git commit was merged and reverted.')
Michael Achenbach 2015/04/21 14:14:24 Is a tool for one commit useful? Why not a whole r
Michael Achenbach 2015/05/04 08:57:53 Could you answer to this? Has that been done? The
+ parser.add_argument("-g", "--git-dir", required=False, default='.',
+ help="The path to your git working directory.")
Michael Achenbach 2015/04/21 14:14:24 nit: indentation
+
+ parser.add_argument('originalCommit', nargs=1, help="Hash of the commit to be searched.")
+ parser.add_argument('upperBound', nargs=1, help="branch when searching should stop.")
+
+ args = sys.argv[1:]
+ options = parser.parse_args(args)
+
+ sys.exit(print_analysis(options.git_dir, options.originalCommit[0], options.upperBound[0]))
« 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