Chromium Code Reviews| 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])) |