From 4e824d06f5b6ef7a694816f9f14e8488d1f7df5c Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Sat, 30 Jul 2022 02:40:01 +0200 Subject: [PATCH] feat: even more fancy log messages --- apatch | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/apatch b/apatch index d6e653e..85be509 100755 --- a/apatch +++ b/apatch @@ -71,25 +71,32 @@ if [ -f "$patch" ]; then fi ( - cd "$builddir" - git init - git add . - git commit -m "$pkgver" >/dev/null + cd "$builddir" + git init + git add . + git commit -m "$pkgver" >/dev/null # if file exists, try to apply if [ -e "$patchpath" ]; then git apply --reject --whitespace=fix "$patchpath" || { - git status --porcelain | grep '\?\? .*\.rej$' | cut -c4- | while read -r reject; do - target="${reject%.rej}" - echo "[*] trying to wiggle $target" - wiggle --merge --replace "$target" "$reject" || { - echo "[!] could not merge $target, fix manually" - } - rm "$reject" - rm "$target.porig" # left by wiggle - done + rejects="$(git status --porcelain | grep '\?\? .*\.rej$' | cut -c4-)" + if [ -n "$rejects" ]; then + warning "$patch partially applied with rejects" + for reject in $rejects; do + target="${reject%.rej}" + msg "trying to wiggle $target" + wiggle --merge --replace "$target" "$reject" || { + warning "could not merge $target, fix manually" + } + rm "$reject" + rm "$target.porig" # left by wiggle + done + else + warning "$patch failed to apply" + fi } fi + msg "you can edit now!" $SHELL