mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-04 11:51:43 +02:00
Adding branch-compare command and renaming clean-branches.py to branch-clean
Change-Id: I8fdb27749893fefbe27bba02437b36e7860701b4
This commit is contained in:
parent
0616e80e01
commit
436ff317af
55
tools/dev/bin/branch-compare
Executable file
55
tools/dev/bin/branch-compare
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from git import Git
|
||||
|
||||
g = Git(os.getcwd())
|
||||
|
||||
commitMsgs = {}
|
||||
|
||||
def getCommits(srcRef, dstRef):
|
||||
commits = {}
|
||||
|
||||
commit = ''
|
||||
changeId = ''
|
||||
commitHash = ''
|
||||
for line in g.log('--format=fuller', '%s..%s' % (srcRef, dstRef)).split('\n'):
|
||||
if len(commit) > 0 and line.find('commit') == 0:
|
||||
commits[changeId] = commitHash
|
||||
commitMsgs[commitHash] = commit
|
||||
commit = ''
|
||||
size = 0
|
||||
match = re.search(r'commit ([0-9a-f]+)', line)
|
||||
if match:
|
||||
commitHash = match.group(1)
|
||||
else:
|
||||
raise Exception('Bad commit hash in line:\n%s' % line)
|
||||
elif line.find('Change-Id:') >= 0:
|
||||
match = re.search(r'Change-Id: (I[0-9a-f]+)', line)
|
||||
if match:
|
||||
changeId = match.group(1)
|
||||
else:
|
||||
raise Exception('Bad Change-Id in line:\n%s' % line)
|
||||
commit += line + '\n'
|
||||
|
||||
return commits
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
sourceRef, targetRef = sys.argv[1:3]
|
||||
except ValueError:
|
||||
print 'branch-compare <source ref> <target ref>'
|
||||
|
||||
targetCommits = getCommits(sourceRef, targetRef)
|
||||
sourceCommits = getCommits(targetRef, sourceRef)
|
||||
|
||||
missingCommitsFromTarget = set(sourceCommits.keys()) - set(targetCommits.keys())
|
||||
|
||||
for id in missingCommitsFromTarget:
|
||||
hash = sourceCommits[id]
|
||||
print 'git cherry-pick', hash
|
||||
print commitMsgs[hash]
|
||||
Loading…
x
Reference in New Issue
Block a user