Welcome to little lamb

Code » comain » commit 4dc6b27

mkrelease: Some tweaks

author Olivier Brunel
2023-07-23 13:37:43 UTC
committer Olivier Brunel
2023-07-24 07:42:26 UTC
parent e72dd70af6beac6a7df009588205ab04343dbea5

mkrelease: Some tweaks

mkrelease +48 -7

diff --git a/mkrelease b/mkrelease
index b5d9024..2e5cb45 100755
--- a/mkrelease
+++ b/mkrelease
@@ -5,6 +5,16 @@
 if test ! -e meta/version; then error 2 "File 'meta/version' missing"; fi
 ver="$(cat meta/version)"
 
+force=0
+if test "$1" = "-f"; then
+    force=1
+    shift
+    if test "$1" = "-f"; then
+        force=2
+        shift
+    fi
+fi
+
 major=$(echo $ver | cut -d. -f1)
 minor=$(echo $ver | cut -d. -f2)
 rev=$(echo $ver | cut -d. -f3)
@@ -20,13 +30,33 @@ new=$major.$minor.$rev
 echo " => bumping $ver to $new..."
 date="$(date +%Y-%m-%d)"
 
-if test "$(git symbolic-ref --short HEAD)" != "next"; then
-    error 2 "next is not checked out"
+if test "$(git symbolic-ref --short HEAD)" != "master"; then
+    error 2 "master is not checked out"
 fi
 if test -n "$(git status -s)"; then
     error 2 "working tree not clean"
 fi
 
+was_master=$(git show-ref --heads --hash master)
+if ! test "$(git show-ref --heads --hash dev)" = "$was_master"; then
+    if test $force -ge 1; then
+        force=$(( $force - 1 ))
+        echo "Ignoring that dev and master differ..."
+        was_master=
+    else
+        error 1 "dev and master differ (-f to ignore)"
+    fi
+fi
+
+if test $force -ge 1; then
+    echo "Ignoring possible XXX/TODO/FIXME..."
+elif ! git xxx -q; then
+    echo "  -> Might be things left to do..."
+    git xxx
+    echo "Use -f to force the release anyway."
+    exit 1
+fi
+
 echo "  -> Checking for new man pages..."
 git diff --name-only --diff-filter=A $(cat meta/version) -- doc \
     | while read -r file ; do
@@ -69,8 +99,11 @@ else
 $line
 
 EOF
-    git log --no-decorate --format='- %s%n%n  %b%n  Thanks to %an <%ae>%n%n' \
-        $(cat meta/version)..HEAD
+    git log --reverse --no-decorate \
+        --format='- %s%n%w(,2,2)%+b%nThanks to %an <%ae>%n%n' \
+        $(cat meta/version)..master \
+        | awk -vskip=0 '/Thanks to Olivier Brunel/ { skip=1; next }
+            // { if (skip) { skip=0 } else { print } }'
     tail -n +3 meta/HISTORY
     exec 1>&5 5<&-
 fi
@@ -89,11 +122,19 @@ git add meta/{version,released-on,HISTORY}
 git commit -m "Release version $new"
 
 echo "  -> Tag & fast-forward"
-git checkout master
-git merge --ff-only next
+git checkout release
+git merge --ff-only master
 git tag -a $new -m "Release version $new
 
 $(getchangelog)"
-git checkout next
+
+if test -n "$was_master"; then
+    echo "  -> Reset dev & rebase dev-wip..."
+    git branch -f dev master
+    git rebase --onto dev $was_master dev-wip
+else
+    echo "  -> Check out (untouched) dev-wip..."
+    git checkout dev-wip
+fi
 
 echo "done."