aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-04-04 09:42:21 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-10-07 11:02:08 +0200
commitb199083197af6d404f9cab31658ae243caedea65 (patch)
tree71fe62e14c5e5036ddb5475eb997ce07adce5842
parent8d6e7bbc72f245aa51c966178f60dd5d5e3d4091 (diff)
downloadgosc-b199083197af6d404f9cab31658ae243caedea65.tar.gz
feat(git-format-named-patches): POC for the script.
Just runs individual commits through `git format-patch(1)` and saves them in the named patch files.
-rw-r--r--README.md2
-rwxr-xr-xgit-format-named-patches.sh19
2 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index 5499271..2896a95 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,8 @@ git-oci
goscb
: (probably not needed, when the checkout is primed with `git-obranch`) run `osc build` without regards if `.osc/` directory exists.
+git-format-named-patches.sh
+: similar to `git format-patch` except the patch files are named according to `Patch: ` trailer in the commit message.
All issues, questions, complaints, or (even better!) patches
should be send via email to
diff --git a/git-format-named-patches.sh b/git-format-named-patches.sh
new file mode 100755
index 0000000..e311f5f
--- /dev/null
+++ b/git-format-named-patches.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -eu
+
+fail() {
+ printf "%s\n" "$1" >>/dev/stderr
+ exit 32
+}
+
+[ "$#" -lt 1 ] && exit 64
+
+IDSstr="$(git log --format="%H" "$1" 2>/dev/null)"
+mapfile -t IDS <<< "$IDSstr"
+for id in "${IDS[@]}" ; do
+ PATCH="$(git format-patch -1 --stdout "${id}")"
+ FN="$(echo "$PATCH" | awk '/^Patch: / {print $2}')"
+ [ -z "$FN" ] && fail "Patch filename not defined"
+ printf "%s" "$PATCH" > "$FN"
+done