Browse Source

🔨 Improved mfprep script

Scott Lahteine 2 years ago
parent
commit
9e43ec9dcd
1 changed files with 19 additions and 5 deletions
  1. 19
    5
      buildroot/share/git/mfprep

+ 19
- 5
buildroot/share/git/mfprep View File

@@ -2,11 +2,16 @@
2 2
 #
3 3
 # mfprep tag1 [tag2]
4 4
 #
5
-# Find commits in bugfix-2.0.x not yet in 2.0.x
5
+# Find commits in bugfix-2.0.x that are not yet in 2.0.x.
6
+#
7
+# Specify a version tag to start from, and optional version tag to end at.
8
+# For bugfix-2.0.x the tag will be prefixed by bf- to distinguish it from the version tag,
9
+# so at every release be sure to create a bf- tag and publish it to origin.
6 10
 #
7 11
 
8 12
 SED=$(which gsed sed | head -n1)
9 13
 SELF=`basename "$0"`
14
+DRYRUN=0
10 15
 
11 16
 [[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; }
12 17
 
@@ -38,13 +43,22 @@ git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "C
38 43
 
39 44
 cat "$LOG2" | while read line; do
40 45
   #echo "... $line"
41
-  if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then
42
-    PATT=${BASH_REMATCH[1]}
46
+  if [[ $line =~ \(((#[0-9]{5}),* *)((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?\)$ ]]; then
47
+    PATT=""
48
+    for i in ${!BASH_REMATCH[@]}; do
49
+      if ((i > 0 && (i % 2 == 0))); then
50
+        if [[ -n "${BASH_REMATCH[i]}" ]]; then
51
+          [[ -n "$PATT" ]] && PATT="$PATT|"
52
+          PATT="$PATT${BASH_REMATCH[i]}"
53
+        fi
54
+      fi
55
+    done
43 56
     #echo "... $PATT"
57
+    [[ -n $PATT ]] && { grep -vE "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
44 58
   else
45 59
     PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" )
60
+    [[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
46 61
   fi
47
-  [[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
48 62
 done
49 63
 
50 64
 # Convert remaining commits into git commands
@@ -62,4 +76,4 @@ done
62 76
 mv "$TMPF" "$SCRF"
63 77
 chmod ug+x "$SCRF"
64 78
 
65
-open "$TMPDIR"
79
+((DRYRUN)) && rm -r "$TMPDIR" || open "$TMPDIR"

Loading…
Cancel
Save