-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Script 'mfprep' finds pending commits
- Loading branch information
1 parent
5efef86
commit a0a5740
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# mfprep tag1 [tag2] | ||
# | ||
# Find commits in bugfix-2.0.x not yet in 2.0.x | ||
# | ||
|
||
SED=$(which gsed sed | head -n1) | ||
SELF=`basename "$0"` | ||
|
||
[[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; } | ||
|
||
TAG1=$1 | ||
TAG2=${2:-"HEAD"} | ||
|
||
# Validate that the required tags exist | ||
|
||
MTAG=`git tag | grep -e "^bf-$TAG1\$"` | ||
[[ -n $MTAG ]] || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } | ||
MTAG=`git tag | grep -e "^$TAG1\$"` | ||
[[ -n $MTAG ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } | ||
|
||
# Generate log of recent commits for bugfix-2.0.x and 2.0.x | ||
|
||
TMPDIR=`mktemp -d` | ||
LOGB="$TMPDIR/log-bf.txt" | ||
LOG2="$TMPDIR/log-20x.txt" | ||
TMPF="$TMPDIR/tmp.txt" | ||
SCRF="$TMPDIR/update-20x.sh" | ||
|
||
git checkout bugfix-2.0.x | ||
git log --pretty="[%h] %s" bf-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB" | ||
|
||
git checkout 2.0.x | ||
git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } | ||
|
||
# Go through commit text from 2.0.x removing all matches from the bugfix log | ||
|
||
cat "$LOG2" | while read line; do | ||
#echo "... $line" | ||
if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then | ||
PATT=${BASH_REMATCH[1]} | ||
#echo "... $PATT" | ||
else | ||
PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" ) | ||
fi | ||
[[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } | ||
done | ||
|
||
# Convert remaining commits into git commands | ||
|
||
echo -e "#!/usr/bin/env bash\nset -e\ngit checkout 2.0.x\n" >"$TMPF" | ||
cat "$LOGB" | while read line; do | ||
if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then | ||
CID=${BASH_REMATCH[1]} | ||
REST=${BASH_REMATCH[2]} | ||
echo "git cherry-pick $CID ;# $REST" >>"$TMPF" | ||
else | ||
echo ";# $line" >>"$TMPF" | ||
fi | ||
done | ||
mv "$TMPF" "$SCRF" | ||
|
||
open "$TMPDIR" |