git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: git@vger.kernel.org
Cc: Ryan Anderson <ryan@michonline.com>,
	Bagas Sanjaya <bagasdotme@gmail.com>
Subject: [PATCH 1/3] request-pull: introduce display_message() function
Date: Sun,  3 Oct 2021 19:29:41 +0700	[thread overview]
Message-ID: <20211003122943.338199-2-bagasdotme@gmail.com> (raw)
In-Reply-To: <20211003122943.338199-1-bagasdotme@gmail.com>

Move displaying PR message logic into display_message. While at it, use
local variable $format and $dashline to shorten argument typing to git
show.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 git-request-pull.sh | 57 ++++++++++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 2d0e44656c..88a7a9cf0d 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -136,37 +136,50 @@ fi
 
 url=$(git ls-remote --get-url "$url")
 
-git show -s --format='The following changes since commit %H:
+display_message() {
+	local format
+	local dash_line
+
+	dash_line="----------------------------------------------------------------"
+	format='The following changes since commit %H:
 
   %s (%ci)
 
 are available in the Git repository at:
-' $merge_base &&
-echo "  $url $pretty_remote" &&
-git show -s --format='
-for you to fetch changes up to %H:
+'
+
+	git show -s --format="$format" $merge_base &&
+	echo "  $url $pretty_remote" &&
+	format='for you to fetch changes up to %H:
 
   %s (%ci)
+'
+	git show -s --format="
+$format
+$dash_line" $headrev &&
 
-----------------------------------------------------------------' $headrev &&
+	if test $(git cat-file -t "$head") = tag
+	then
+		git cat-file tag "$head" |
+		sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p
+		echo
+		echo "$dash_line"
+	fi &&
 
-if test $(git cat-file -t "$head") = tag
-then
-	git cat-file tag "$head" |
-	sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p
-	echo
-	echo "----------------------------------------------------------------"
-fi &&
+	if test -n "$branch_name"
+	then
+		echo "(from the branch description for $branch_name local branch)"
+		echo
+		git config "branch.$branch_name.description"
+		echo "$dash_line"
+	fi &&
 
-if test -n "$branch_name"
-then
-	echo "(from the branch description for $branch_name local branch)"
-	echo
-	git config "branch.$branch_name.description"
-	echo "----------------------------------------------------------------"
-fi &&
+	git shortlog ^$baserev $headrev &&
+	git diff -M --stat --summary $patch $merge_base..$headrev
+}
 
-git shortlog ^$baserev $headrev &&
-git diff -M --stat --summary $patch $merge_base..$headrev || status=1
+message=$(display_message) || status=1
+
+echo "$message"
 
 exit $status
-- 
An old man doll... just what I always wanted! - Clara


  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 ` Bagas Sanjaya [this message]
2021-10-03 12:29 ` [PATCH 2/3] request-pull: add -o/--output option Bagas Sanjaya
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-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).