Browse Source

🔨 Script 'mfprep' finds pending commits

Scott Lahteine 2 years ago
parent
commit
02b6fb8025
1 changed files with 64 additions and 0 deletions
  1. 64
    0
      buildroot/share/git/mfprep

+ 64
- 0
buildroot/share/git/mfprep View File

@@ -0,0 +1,64 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfprep tag1 [tag2]
4
+#
5
+# Find commits in bugfix-2.0.x not yet in 2.0.x
6
+#
7
+
8
+SED=$(which gsed sed | head -n1)
9
+SELF=`basename "$0"`
10
+
11
+[[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; }
12
+
13
+TAG1=$1
14
+TAG2=${2:-"HEAD"}
15
+
16
+# Validate that the required tags exist
17
+
18
+MTAG=`git tag | grep -e "^bf-$TAG1\$"`
19
+[[ -n $MTAG ]] || { echo "Can't find tag bf-$TAG1" ; exit 1 ; }
20
+MTAG=`git tag | grep -e "^$TAG1\$"`
21
+[[ -n $MTAG ]] || { echo "Can't find tag $TAG1" ; exit 1 ; }
22
+
23
+# Generate log of recent commits for bugfix-2.0.x and 2.0.x
24
+
25
+TMPDIR=`mktemp -d`
26
+LOGB="$TMPDIR/log-bf.txt"
27
+LOG2="$TMPDIR/log-20x.txt"
28
+TMPF="$TMPDIR/tmp.txt"
29
+SCRF="$TMPDIR/update-20x.sh"
30
+
31
+git checkout bugfix-2.0.x
32
+git log --pretty="[%h] %s" bf-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB"
33
+
34
+git checkout 2.0.x
35
+git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag bf-$TAG1" ; exit 1 ; }
36
+
37
+# Go through commit text from 2.0.x removing all matches from the bugfix log
38
+
39
+cat "$LOG2" | while read line; do
40
+  #echo "... $line"
41
+  if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then
42
+    PATT=${BASH_REMATCH[1]}
43
+    #echo "... $PATT"
44
+  else
45
+    PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" )
46
+  fi
47
+  [[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; }
48
+done
49
+
50
+# Convert remaining commits into git commands
51
+
52
+echo -e "#!/usr/bin/env bash\nset -e\ngit checkout 2.0.x\n" >"$TMPF"
53
+cat "$LOGB" | while read line; do
54
+  if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then
55
+    CID=${BASH_REMATCH[1]}
56
+    REST=${BASH_REMATCH[2]}
57
+    echo "git cherry-pick $CID ;# $REST" >>"$TMPF"
58
+  else
59
+    echo ";# $line" >>"$TMPF"
60
+  fi
61
+done
62
+mv "$TMPF" "$SCRF"
63
+
64
+open "$TMPDIR"

Loading…
Cancel
Save