Welcome to little lamb

Code » comain » commit fdda91b

mkrelease: Add automatic changes for man pages & HISTORY

author Olivier Brunel
2023-02-03 18:56:53 UTC
committer Olivier Brunel
2023-02-03 18:56:53 UTC
parent 69cb77f7a1375d9d092ac6342d759bc721a8a641

mkrelease: Add automatic changes for man pages & HISTORY

- Added files in doc are treated as man pages and date/version are added
- Modified files in doc are treated as man pages and date/version are
  replaced (full lines 3 & 4 are replaced, actually)

There are no checks, but the adding (git add) is done with patch editing
so it can be reviewed/edited if needed.

Also, change log (from git) is inserted into HISTORY which is edited for
review/adjustments before being added (and everything committed).

mkrelease +30 -5

diff --git a/mkrelease b/mkrelease
index 85c4a76..b5d9024 100755
--- a/mkrelease
+++ b/mkrelease
@@ -27,11 +27,26 @@ if test -n "$(git status -s)"; then
     error 2 "working tree not clean"
 fi
 
-echo "  -> Updating meta/version : $new"
-echo $new > meta/version
+echo "  -> Checking for new man pages..."
+git diff --name-only --diff-filter=A $(cat meta/version) -- doc \
+    | while read -r file ; do
+    echo "    * Updating $file..."
+    { head -n 2 "$file"; echo "% $prjname $new"; echo "% $date"; tail -n +3 "$file"; } > "$file.tmp"
+    mv -f "$file.tmp" "$file"
+done
+
+echo "  -> Checking for modified man pages..."
+git diff --name-only --diff-filter=M $(cat meta/version) -- doc \
+    | while read -r file ; do
+    echo "    * Updating $file..."
+    { head -n 2 "$file"; echo "% $prjname $new"; echo "% $date"; tail -n +5 "$file"; } > "$file.tmp"
+    mv -f "$file.tmp" "$file"
+done
 
-echo "  -> Updating meta/released-on : $date"
-echo $date > meta/released-on
+if test -n "$(git status -s)"; then
+    echo "  -> Adding automatic changes..."
+    git add -e -- doc
+fi
 
 echo "  -> Updating meta/HISTORY"
 line="# version $new [released on $date]"
@@ -54,12 +69,22 @@ else
 $line
 
 EOF
+    git log --no-decorate --format='- %s%n%n  %b%n  Thanks to %an <%ae>%n%n' \
+        $(cat meta/version)..HEAD
     tail -n +3 meta/HISTORY
     exec 1>&5 5<&-
 fi
 mv -f meta/HISTORY{.tmp,}
+echo "  -> Review updated HISTORY..."
+${EDITOR:vim} meta/HISTORY
+
+echo "  -> Updating meta/version : $new"
+echo $new > meta/version
+
+echo "  -> Updating meta/released-on : $date"
+echo $date > meta/released-on
 
-echo "  -> Commit meta/{version,released-on,HISTORY}"
+echo "  -> Commit changes..."
 git add meta/{version,released-on,HISTORY}
 git commit -m "Release version $new"