Last active
December 14, 2016 14:08
-
-
Save soyo42/9ace2459e05742c7bb8f to your computer and use it in GitHub Desktop.
lineup and summarize changes on master and branch in order to hint cherry-picking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is project name keeper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.??* | |
!.Git_cherrypicks_lineup_script | |
!.gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SHA1 of revision which the branch is based on (last common point) | |
branchStartRev='244c0d7016565d72fb3596483e58c80ead9dfad7' | |
# name of the branch | |
releaseBranch='stable/helium' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$2" ]; then | |
echo "usage:: $0 <start revision> <end revision>" | |
exit 1 | |
fi | |
git log --no-merges --format=oneline $1..$2 | colrm 1 40 | tac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cherries summarizer | |
=================== | |
Aligns master and branch changes in order to hint what is missing in branch | |
and should be cherry-picked. | |
Alignment is based on first line of commit message so please keep the first | |
line unchanged when cherry-picking. | |
Final comparison uses diffuse. If you want to use some different diff tool then | |
just edit the one but last line of summarizeCherries.sh. (e.g.: meld, kdiff3, diff ..) | |
Quick start | |
=========== | |
- copy example.project to .<project origin url server name>--<project name> | |
cp example.project .git.opendaylight.org--controller | |
- edit content of this config (as comments say - we need | |
SHA1 of common point and branch name) | |
- create symbolic links of summarizeCherries.sh to ${HOME}/bin (or to any other directory on PATH) | |
ln -s summarizeCherries.sh ~/bin/ | |
- go into project folder and run | |
summarizeCherries.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
if len(sys.argv) != 3: | |
sys.stderr.write('usage:: {0} <source history messages> <cherry-target history messages>\n') | |
sys.exit(1) | |
with open(sys.argv[1], 'r') as source: | |
srcList = source.readlines() | |
with open(sys.argv[2], 'r') as subset: | |
cherryList = subset.readlines() | |
def lookupCherry(lookupList, item): | |
needles = [] | |
flag = None | |
#sys.stdout.write('#{0}'.format(item)) | |
for line in lookupList: | |
if line.find(item.strip()) >= 0 or item.find(line.strip()) >= 0: | |
if line.startswith(' Revert'): | |
tmpFlag = '-' | |
else: | |
tmpFlag = '' | |
if tmpFlag != flag: | |
flag = tmpFlag | |
needles.append(line) | |
if len(needles) == 0: | |
needles = None | |
return (needles, flag) | |
for line in srcList: | |
(cherryLines, flag) = lookupCherry(cherryList, line) | |
if cherryLines != None: | |
prettyCherry = cherryLines[0] | |
if flag: | |
prettyCherry = flag + prettyCherry[1:] | |
sys.stdout.write(prettyCherry) | |
for checked in cherryLines: | |
cherryList.remove(checked) | |
else: | |
sys.stdout.write('\n') | |
sys.stdout.write('---\n') | |
for cherryLine in cherryList: | |
sys.stdout.write(cherryLine) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read projKey; do | |
key="${projKey}" | |
if [ -n "$1" ]; then | |
key="${key}_$1" | |
fi | |
echo "cherries at: ${key}" | |
SCRIPT_ROOT="$(dirname "$(readlink -f $0)")" | |
config="${SCRIPT_ROOT}/.${key}" | |
if [ ! -f "${config}" ]; then | |
echo "${config} not found" | |
continue | |
fi | |
masterBranch='master' | |
. ${config} | |
refBranchSuffix="${masterBranch//\//_}" | |
trgBranchSuffix="${releaseBranch//\//_}" | |
harvestHistoryMsg.sh ${branchStartRev} ${masterBranch} > ../${projKey}_${refBranchSuffix}.history | |
harvestHistoryMsg.sh ${branchStartRev} ${releaseBranch} > ../${projKey}_${trgBranchSuffix}.history | |
pushd .. | |
${SCRIPT_ROOT}/lineupHistoryMsg.py ${projKey}_${refBranchSuffix}.history ${projKey}_${trgBranchSuffix}.history > ${projKey}_${trgBranchSuffix}.history.aligned | |
diffuse ${projKey}_${refBranchSuffix}.history ${projKey}_${trgBranchSuffix}.history.aligned | |
popd | |
done < <(git remote -v | sed -r 's/^.+@([a-z0-9\.-]+)(:[0-9]+)?\/(.*\/)?([_0-9a-z-]+)(\.git| ).+$/\1--\4/' | sort -u) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment