From: Bagas Sanjaya <bagasdotme@gmail.com>
To: git@vger.kernel.org
Cc: Ryan Anderson <ryan@michonline.com>,
Bagas Sanjaya <bagasdotme@gmail.com>
Subject: [PATCH 2/3] request-pull: add -o/--output option
Date: Sun, 3 Oct 2021 19:29:42 +0700 [thread overview]
Message-ID: <20211003122943.338199-3-bagasdotme@gmail.com> (raw)
In-Reply-To: <20211003122943.338199-1-bagasdotme@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2021-10-03 12:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-03 12:29 [PATCH 0/3] request-pull: write to file option Bagas Sanjaya
2021-10-03 12:29 ` [PATCH 1/3] request-pull: introduce display_message() function Bagas Sanjaya
2021-10-03 12:29 ` Bagas Sanjaya [this message]
2021-10-03 12:29 ` [PATCH 3/3] request-pull: document -o/--output Bagas Sanjaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211003122943.338199-3-bagasdotme@gmail.com \
--to=bagasdotme@gmail.com \
--cc=git@vger.kernel.org \
--cc=ryan@michonline.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.