nixpkgs-ml-tools

nixpkgs mailing list tools
git clone git://jb55.com/nixpkgs-ml-tools
Log | Files | Refs | README | LICENSE

commit 266f7a88a7c0bbd44c2fe68f3604c61acbbb35cc
parent 241cd6325eb2748852b65c9365ce04cf58caa06c
Author: Matthias Beyer <mail@beyermatthias.de>
Date:   Thu,  1 Apr 2021 20:39:46 +0200

Add support for calling git-am right away

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Tested-by: Matthias Beyer <mail@beyermatthias.de>
Link: https://lore.kernel.org/r/20210401183949.25894-3-mail@beyermatthias.de

Diffstat:
Mnotmuch-am | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/notmuch-am b/notmuch-am @@ -25,13 +25,15 @@ begins_with_short_option() # THE DEFAULTS INITIALIZATION - POSITIONALS _positionals=() # THE DEFAULTS INITIALIZATION - OPTIONALS +_arg_am="off" print_help() { printf '%s\n' "Use b4 to apply a patchset from a thread." - printf 'Usage: %s [-h|--help] <thread-id>\n' "$0" + printf 'Usage: %s [-h|--help] [--(no-)am] <thread-id>\n' "$0" printf '\t%s\n' "<thread-id>: The notmuch thread id of the thread to apply" + printf '\t%s\n' "--am, --no-am: Call git-am instead of generating a mbox file (off by default)" printf '\t%s\n' "-h, --help: Prints help" printf %s "\ @@ -61,6 +63,10 @@ parse_commandline() print_help exit 0 ;; + --no-am|--am) + _arg_am="on" + test "${1:0:5}" = "--no-" && _arg_am="off" + ;; *) _last_positional="$1" _positionals+=("$_last_positional") @@ -112,7 +118,13 @@ main () { mbox=$(mktemp) notmuch show --format=mbox "$1" > "$mbox" msgid=$(grep -i ^message-id "$mbox" | cut -d" " -f2 | head -n1) - b4 am "$B4AM_ARGS" "$msgid" -m "$mbox" + + if [[ "$_arg_am" == "on" ]]; then + b4 am "msgid" -m "$mbox" -o - | git am + else + b4 am "$B4AM_ARGS" "$msgid" -m "$mbox" + fi + rm -f "$mbox" }