Add -o option (and long dash counterpart --option), which allow users to write pull request message to the specified file. Signed-off-by: Bagas Sanjaya <bagasdotme@xxxxxxxxx> --- git-request-pull.sh | 28 +++++++++++++++++++++++----- t/t5150-request-pull.sh | 13 +++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/git-request-pull.sh b/git-request-pull.sh index 88a7a9cf0d..f4d6f846d0 100755 --- a/git-request-pull.sh +++ b/git-request-pull.sh @@ -7,10 +7,12 @@ SUBDIRECTORY_OK='Yes' OPTIONS_KEEPDASHDASH= OPTIONS_STUCKLONG= -OPTIONS_SPEC='git request-pull [options] start url [end] +OPTIONS_SPEC="\ +git request-pull [options] start url [end] -- -p show patch text as well -' +p show patch text as well +o,output= output pull request to the specified file +" . git-sh-setup @@ -18,11 +20,16 @@ GIT_PAGER= export GIT_PAGER patch= -while case "$#" in 0) break ;; esac +out= +while test $# != 0 do case "$1" in -p) patch=-p ;; + -o|--output) + case "$2" in '') usage ;; esac + out="$2" + shift ;; --) shift; break ;; -*) @@ -180,6 +187,17 @@ $dash_line" $headrev && message=$(display_message) || status=1 -echo "$message" +if test $status -ne 0 +then + echo "There's an error when outputting message, exiting" + exit $status +fi + +if test -n "$out" +then + echo "$message" > "$out" +else + echo "$message" +fi exit $status diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index cb67bac1c4..b87e9c9869 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -168,6 +168,19 @@ test_expect_success 'pull request after push' ' ' +test_expect_success 'pull request output with -o' ' + + rm -fr downstream.git && + git init --bare downstream.git && + ( + cd local && + git checkout initial && + git merge --ff-only main && + git push origin main:for-upstream && + git request-pull -o ../request initial origin main:for-upstream + ) +' + test_expect_success 'request asks HEAD to be pulled' ' rm -fr downstream.git && -- An old man doll... just what I always wanted! - Clara