Index: tools/release/mergeinfo.py |
diff --git a/tools/release/mergeinfo.py b/tools/release/mergeinfo.py |
index bf07e9f94af9ed47c959fbd58384b9ae21679649..d71914e204ce4c7ba1c7ad9439870736f086a94b 100755 |
--- a/tools/release/mergeinfo.py |
+++ b/tools/release/mergeinfo.py |
@@ -7,29 +7,72 @@ import argparse |
import os |
import sys |
-from subprocess import call |
+from search_related_commits import git_execute |
+ |
+def describe_commit(gitWorkingDir, hashToSearch, prettyPrint=True): |
Michael Achenbach
2015/09/17 14:19:00
nit: Still think our python style guide recommends
Michael Hablich
2015/09/18 07:38:47
I sticked to the style which was already present .
|
+ if not prettyPrint: |
+ return git_execute(gitWorkingDir, ['show', |
+ '--quiet', |
+ '--pretty=format:%H', |
Michael Achenbach
2015/09/17 14:19:00
Could you deduplicate this code? E.g. using someth
Michael Hablich
2015/09/18 07:38:47
Makes sense, will do.
|
+ hashToSearch]).strip() |
+ |
+ return git_execute(gitWorkingDir, ['show', |
+ '--quiet', |
+ hashToSearch]).strip() |
+ |
+ |
+def get_followup_commits(gitWorkingDir, hashToSearch, prettyPrint=True): |
+ if not prettyPrint: |
+ raise Exception("NotImplemented") |
Michael Achenbach
2015/09/17 14:19:00
So: The non-pretty printed version wouldn't work y
Michael Hablich
2015/09/18 07:38:47
Well, it started out as an idea to simply add the
|
+ git_execute(gitWorkingDir, ['log', |
+ '--grep='+hashToSearch, |
Michael Achenbach
2015/09/17 14:19:00
nit: indentation.
Michael Hablich
2015/09/18 07:38:47
Acknowledged.
|
+ '--oneline', |
+ 'master']).strip() |
+ |
+def get_merge_commits(gitWorkingDir, hashToSearch): |
+ merges = git_execute(gitWorkingDir, ['log', |
+ '--all', |
Michael Achenbach
2015/09/17 14:19:00
nit: indentation
Michael Hablich
2015/09/18 07:38:47
Acknowledged.
|
+ '--grep='+hashToSearch, |
+ '--oneline', |
+ '--decorate', |
+ '--not', |
+ 'master', |
+ '--pretty=format:%H']) |
+ merges = merges.splitlines() |
+ return merges |
def print_analysis(gitWorkingDir, hashToSearch): |
- print '1.) Info' |
- git_execute(gitWorkingDir, ['status']) |
- print '2.) Searching for "' + hashToSearch + '"' |
- print '=====================ORIGINAL COMMIT START=====================' |
- git_execute(gitWorkingDir, ['show', hashToSearch]) |
+ print '1.) Searching for "' + hashToSearch + '"' |
+ print '=====================ORIGINAL COMMIT START===================' |
+ print describe_commit(gitWorkingDir, hashToSearch, True) |
print '=====================ORIGINAL COMMIT END=====================' |
- print '#####################FOUND MERGES & REVERTS START#####################' |
- git_execute(gitWorkingDir, ["log",'--all', '--grep='+hashToSearch]) |
- print '#####################FOUND MERGES & REVERTS END#####################' |
+ print '2.) Found follow-up commits, reverts and ports:' |
+ print get_followup_commits(gitWorkingDir, hashToSearch, True) |
+ print '3.) Found merges:' |
+ merges = get_merge_commits(gitWorkingDir, hashToSearch) |
+ for currentMerge in merges: |
+ print git_execute(gitWorkingDir, ['show', |
+ '--oneline', |
+ '--quiet', |
+ currentMerge]).strip() |
+ print '---Merged to:' |
+ mergeOutput = git_execute(gitWorkingDir, ['branch', |
+ '--contains', |
+ currentMerge, |
+ '-r']).strip() |
+ print '---' + mergeOutput |
print 'Finished successfully' |
-def git_execute(workingDir, commands): |
- return call(["git", '-C', workingDir] + commands) |
-if __name__ == "__main__": # pragma: no cover |
- parser = argparse.ArgumentParser('Tool to check where a git commit was merged and reverted.') |
- parser.add_argument("-g", "--git-dir", required=False, default='.', |
- help="The path to your git working directory.") |
+if __name__ == '__main__': # pragma: no cover |
+ parser = argparse.ArgumentParser('''Tool to check where a git commit was |
Michael Achenbach
2015/09/17 14:19:00
nit: I wouldn't use ''' as this will add the lineb
Michael Hablich
2015/09/18 07:38:47
Acknowledged.
|
+ merged and reverted.''') |
+ parser.add_argument('-g', '--git-dir', required=False, default='.', |
+ help='The path to your git working directory.') |
- parser.add_argument('hash', nargs=1, help="Hash of the commit to be searched.") |
+ parser.add_argument('hash', |
+ nargs=1, |
+ help='Hash of the commit to be searched.') |
args = sys.argv[1:] |
options = parser.parse_args(args) |