diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-04-04 09:42:21 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-10-07 11:02:08 +0200 |
commit | b199083197af6d404f9cab31658ae243caedea65 (patch) | |
tree | 71fe62e14c5e5036ddb5475eb997ce07adce5842 | |
parent | 8d6e7bbc72f245aa51c966178f60dd5d5e3d4091 (diff) | |
download | gosc-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.md | 2 | ||||
-rwxr-xr-x | git-format-named-patches.sh | 19 |
2 files changed, 21 insertions, 0 deletions
@@ -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 |