Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2015 the V8 project 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 | |
| 6 import argparse | |
| 7 import os | |
| 8 import sys | |
| 9 | |
| 10 from subprocess import call, Popen, PIPE | |
| 11 | |
| 12 def print_analysis(gitWorkingDir, hashToSearch, upperBound): | |
|
Michael Achenbach
2015/04/21 14:14:24
nit: python var names
| |
| 13 | |
| 14 raw_output = git_execute(gitWorkingDir, ["rev-list", hashToSearch + ".." + upp erBound]) | |
|
Michael Achenbach
2015/04/21 14:14:24
Suggestiong: you could use log on origin/master wi
| |
| 15 | |
| 16 print 'test' | |
| 17 raw_output = raw_output.strip() | |
| 18 candidate_hashes = raw_output.split("\n") | |
|
Michael Achenbach
2015/04/21 14:14:24
splitlines()
| |
| 19 print "Found " + str(len(candidate_hashes)) + " candidates" | |
| 20 for candidate in candidate_hashes: | |
| 21 #git show -s --format=%B SHA1 | |
| 22 current_message = git_execute(gitWorkingDir, ["show","-s", "--format=%B",can didate]) | |
| 23 if ("Revert" in current_message) or ("revert" in current_message): | |
| 24 if hashToSearch in current_message: | |
| 25 print "Found revert in " + candidate | |
| 26 | |
| 27 print "Finished" | |
| 28 | |
|
Michael Achenbach
2015/04/21 14:14:24
nit: two empty lines between things on toplevel
| |
| 29 def git_execute(workingDir, commands): | |
|
Michael Achenbach
2015/04/21 14:14:24
working_dir
| |
| 30 p = Popen(['git', '-C', workingDir] + commands, stdin=PIPE, stdout=PIPE, stder r=PIPE) | |
| 31 output, err = p.communicate() | |
| 32 rc = p.returncode | |
| 33 if rc != 0: | |
| 34 raise Exception(err) | |
| 35 | |
| 36 return output | |
| 37 | |
| 38 if __name__ == "__main__": # pragma: no cover | |
| 39 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
| |
| 40 parser.add_argument("-g", "--git-dir", required=False, default='.', | |
| 41 help="The path to your git working directory.") | |
|
Michael Achenbach
2015/04/21 14:14:24
nit: indentation
| |
| 42 | |
| 43 parser.add_argument('originalCommit', nargs=1, help="Hash of the commit to be searched.") | |
| 44 parser.add_argument('upperBound', nargs=1, help="branch when searching should stop.") | |
| 45 | |
| 46 args = sys.argv[1:] | |
| 47 options = parser.parse_args(args) | |
| 48 | |
| 49 sys.exit(print_analysis(options.git_dir, options.originalCommit[0], options.up perBound[0])) | |
| OLD | NEW |