diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-01-21 14:31:09 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-01-21 14:31:09 +0000 |
commit | 16ddc215199f94f47bea6be65b6776f061fbb2ac (patch) | |
tree | 77a060b0350761484527f07282c7f8398cc1de94 | |
parent | bfb149d0fab3aae788708ad071eebbc763a4b2d2 (diff) |
New script stg-add-line to add lines to commit messages
The script stg-add-line will perform an 'stg edit', but adding the
first command line argument as its own line at the end of the commit
message, without any user interaction. This is particularly useful
to add reviewed-by and other tags to the commit message:
stg-add-line 'Reviewed-by: Foo Bar <foo@bar.com>' [patchname]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rwxr-xr-x | stg-add-line | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/stg-add-line b/stg-add-line new file mode 100755 index 0000000..097243b --- /dev/null +++ b/stg-add-line @@ -0,0 +1,36 @@ +#!/bin/sh -e +# +# Do an stg edit, but adding the first command line argument as +# its own line at the end of the commit message, without any user interaction. +# Further arguments are passed directly to 'stg edit'; the only really +# useful one is to provide the name of the patch to edit. +# +# Useful for +# stg-add-line 'Reviewed-by: Foo Bar <foo@bar.com>' [patchname] +# +# Copyright (C) 2016 Linaro Limited +# Author: Peter Maydell <peter.maydell@linaro.org> +# This work is licensed under the terms of the GNU GPL version 2 or later. + +# We have to do this by creating a temporary script which we tell +# stg to use as the editor. + +if [ $# -eq 0 ]; then + echo "Usage: stg-add-line line-to-add [other stg edit options]" + exit 1 +fi + +MYLINE="$1" +shift + +EDITSCRIPT="$(mktemp --tmpdir 'stg-add-line-tmp.XXXXXXXXXXX')" +trap 'rm -f -- "$EDITSCRIPT"' INT TERM HUP EXIT + +cat > "$EDITSCRIPT" <<EOT +#!/bin/sh -e +echo '$MYLINE' >> "\$1" +EOT + +chmod u+x "$EDITSCRIPT" + +EDITOR="$EDITSCRIPT" stg edit "$@" |