Skip to content

Commit

Permalink
🔨 Improved mfprep script
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed May 8, 2022
1 parent 1a9e8c0 commit 9e43ec9
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions buildroot/share/git/mfprep
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
#
# mfprep tag1 [tag2]
#
# Find commits in bugfix-2.0.x not yet in 2.0.x
# Find commits in bugfix-2.0.x that are not yet in 2.0.x.
#
# Specify a version tag to start from, and optional version tag to end at.
# For bugfix-2.0.x the tag will be prefixed by bf- to distinguish it from the version tag,
# so at every release be sure to create a bf- tag and publish it to origin.
#

SED=$(which gsed sed | head -n1)
SELF=`basename "$0"`
DRYRUN=0

[[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; }

Expand Down Expand Up @@ -38,13 +43,22 @@ git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "C

cat "$LOG2" | while read line; do
#echo "... $line"
if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then
PATT=${BASH_REMATCH[1]}
if [[ $line =~ \(((#[0-9]{5}),* *)((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?\)$ ]]; then
PATT=""
for i in ${!BASH_REMATCH[@]}; do
if ((i > 0 && (i % 2 == 0))); then
if [[ -n "${BASH_REMATCH[i]}" ]]; then
[[ -n "$PATT" ]] && PATT="$PATT|"
PATT="$PATT${BASH_REMATCH[i]}"
fi
fi
done
#echo "... $PATT"
[[ -n $PATT ]] && { grep -vE "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
else
PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" )
[[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
fi
[[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
done

# Convert remaining commits into git commands
Expand All @@ -62,4 +76,4 @@ done
mv "$TMPF" "$SCRF"
chmod ug+x "$SCRF"

open "$TMPDIR"
((DRYRUN)) && rm -r "$TMPDIR" || open "$TMPDIR"

0 comments on commit 9e43ec9

Please sign in to comment.