git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] request-pull: introduce display_message() function

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Oct 3, 2021, 12:29 UTC
Message-ID
<20211003122943.338199-2-bagasdotme@gmail.com>
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
Previous: Bagas SanjayaNext: Bagas Sanjaya
Message 3 of 4 in “request-pull: write to file option”
  1. 0/3 request-pull: write to file optionBagas Sanjaya, Oct 3, 2021
  2. 2/3 request-pull: add -o/--output optionBagas Sanjaya, Oct 3, 2021
  3. 1/3 request-pull: introduce display_message() functionBagas Sanjaya, Oct 3, 2021
  4. 3/3 request-pull: document -o/--outputBagas Sanjaya, Oct 3, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.