feat: keep original patch headers
This commit is contained in:
parent
833280f1a9
commit
a85bf4c080
1 changed files with 20 additions and 6 deletions
26
apatch
26
apatch
|
@ -62,6 +62,14 @@ for patch in $source; do
|
|||
fi
|
||||
done
|
||||
|
||||
header=""
|
||||
if [ -f "$patch" ]; then
|
||||
msg "patch exists, trying to extract existing message"
|
||||
# try to extract the original header from the patch
|
||||
patch_start=$(grep -En '^(diff --git|--- )' "$patchpath" | cut -d: -f1 | head -n 1)
|
||||
header="$(head -n $(( patch_start - 1 )) "$patchpath"; echo)"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$builddir"
|
||||
git init
|
||||
|
@ -85,10 +93,16 @@ done
|
|||
|
||||
$SHELL
|
||||
|
||||
git add .
|
||||
git diff --cached > "$patchpath"
|
||||
if [ ! -s "$patchpath" ]; then
|
||||
echo "[*] patch is empty, removing"
|
||||
rm "$patchpath"
|
||||
fi
|
||||
git add .
|
||||
|
||||
msg "saving patch $patch"
|
||||
echo -n "$header" > "$patchpath"
|
||||
git diff --cached >> "$patchpath"
|
||||
|
||||
if [ ! -s "$patchpath" ]; then
|
||||
msg "patch is empty, removing"
|
||||
rm "$patchpath"
|
||||
fi
|
||||
|
||||
rm -rf .git
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue