4 changed files with 144 additions and 7 deletions
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# store patch |
||||
file="$(mktemp ${TMPDIR-/tmp}/mutt-patch-apply-XXXXXXXX)" |
||||
trap "rm -f $file" EXIT |
||||
cat > "$file" |
||||
|
||||
# find project |
||||
#source ~/.mutt/bin/patch-find-project.sh |
||||
#if test "$project" = ""; then |
||||
# echo "ERROR: can't figure project" |
||||
# exit 1 |
||||
#fi |
||||
# |
||||
## go! |
||||
#clear |
||||
#cd $HOME/projects/$project |
||||
project=$(pwd) |
||||
branch=$(git rev-parse --abbrev-ref HEAD) |
||||
|
||||
clear |
||||
echo "#" |
||||
echo "# try applying patch to $project, branch $branch" |
||||
echo "#" |
||||
|
||||
if git am --message-id --3way --ignore-whitespace --whitespace=fix "$file"; then |
||||
echo "#" |
||||
echo "# OK" |
||||
echo "#" |
||||
else |
||||
echo "# FAILED, cleaning up" |
||||
cp -v .git/rebase-apply/patch patch-apply-failed.diff |
||||
cp -v "$file" patch-apply-failed.mail |
||||
git am --abort |
||||
git reset --hard |
||||
fi |
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
#!/bin/sh |
||||
if test "$PATCH_PROJECT" != ""; then |
||||
project="$PATCH_PROJECT" |
||||
elif grep -q -e "devel@edk2.groups.io" "$file"; then |
||||
project="edk2" |
||||
elif grep -q -e "qemu-devel@nongnu.org" "$file"; then |
||||
project="qemu" |
||||
# [ ... more checks snipped ... ] |
||||
fi |
||||
if test "$project" = ""; then |
||||
echo "Can't figure project automatically." |
||||
echo "Use env var PATCH_PROJECT to specify path." |
||||
fi |
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# store patch |
||||
file="$(mktemp ${TMPDIR-/tmp}/mutt-patch-queue-XXXXXXXX)" |
||||
trap "rm -f $file" EXIT |
||||
cat > "$file" |
||||
|
||||
# find project |
||||
source ~/.mutt/bin/patch-find-project.sh |
||||
if test "$project" = ""; then |
||||
echo "ERROR: can't figure project" |
||||
exit 1 |
||||
fi |
||||
|
||||
# find msgid |
||||
msgid=$(grep -i -e "^message-id:" "$file" | head -n 1 \ |
||||
| sed -e 's/.*<//' -e 's/>.*//') |
||||
|
||||
# go! |
||||
clear |
||||
cd $HOME/projects/$project |
||||
branch=$(git rev-parse --abbrev-ref HEAD) |
||||
|
||||
clear |
||||
echo "#" |
||||
echo "# try queuing patch (series) for $project, branch $branch" |
||||
echo "#" |
||||
echo "# msgid: $msgid" |
||||
echo "#" |
||||
|
||||
# create work dir |
||||
WORK="${TMPDIR-/tmp}/${0##*/}-$$" |
||||
mkdir "$WORK" || exit 1 |
||||
trap 'rm -rf $file "$WORK"' EXIT |
||||
|
||||
echo "# fetching from lore ..." |
||||
echo "#" |
||||
b4 am --outdir "$WORK" \ |
||||
--apply-cover-trailers \ |
||||
--sloppy-trailers \ |
||||
$msgid || exit 1 |
||||
|
||||
count=$(ls $WORK/*.mbx 2>/dev/null | wc -l) |
||||
if test "$count" = "0"; then |
||||
echo "#" |
||||
echo "# got nothing, trying notmuch instead ..." |
||||
echo "#" |
||||
echo "# update db ..." |
||||
notmuch new |
||||
echo "# find thread ..." |
||||
notmuch show \ |
||||
--format=mbox \ |
||||
--entire-thread=true \ |
||||
id:$msgid > $WORK/notmuch.thread |
||||
echo "# process mails ..." |
||||
b4 am --outdir "$WORK" \ |
||||
--apply-cover-trailers \ |
||||
--sloppy-trailers \ |
||||
--use-local-mbox $WORK/notmuch.thread \ |
||||
$msgid || exit 1 |
||||
count=$(ls $WORK/*.mbx 2>/dev/null | wc -l) |
||||
fi |
||||
|
||||
echo "#" |
||||
echo "# got $count patches, trying to apply ..." |
||||
echo "#" |
||||
if git am -m -3 $WORK/*.mbx; then |
||||
echo "#" |
||||
echo "# OK" |
||||
echo "#" |
||||
else |
||||
echo "# FAILED, cleaning up" |
||||
git am --abort |
||||
git reset --hard |
||||
fi |
Loading…
Reference in new issue