proj/gagit:main commit in: /

Michał Górny <[email protected]> Wed, 05 Aug 2026 10:49:57 +0000 (UTC)
Newsgroups gmane.linux.gentoo.cvs
Message-ID <1785926967.abbc1dee84ba6b4dd69deb1d300cda34c0cd9259.mgorny@gentoo>
commit:     abbc1dee84ba6b4dd69deb1d300cda34c0cd9259
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  5 10:49:27 2026 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  5 10:49:27 2026 +0000
URL:        https://gitweb.gentoo.org/proj/gagit.git/commit/?id=abbc1dee

Default title and description from message, when just one commit

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 gagit | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gagit b/gagit
index 8997789..2c690c6 100755
--- a/gagit
+++ b/gagit
@@ -81,6 +81,11 @@ get_template() {
 	done
 }
 
+format_commits() {
+	local IFS=
+	echo "${*}"
+}
+
 fj_b64() {
 	local data=${1}
 
@@ -223,6 +228,19 @@ main() {
 	echo "Target branch: ${target}" >&2
 
 	local template=$(get_template)
+
+	local commits=()
+	mapfile commits < <(git log --format='# %h %s' "${target}..${branch}")
+	case ${#commits[@]} in
+		0)
+			die "No changes found in ${target}..${branch} range"
+			;;
+		1)
+			: "${title:=$(git log --format='WIP: %s' -1)}"
+			: "${description:=$(git log --format='%b' -1)}"
+			;;
+	esac
+
 	: "${title:=WIP: ${topic}}"
 
 	tempdir=$(mktemp -d) || die "Unable to create a temporary directory"
@@ -241,7 +259,7 @@ main() {
 		${description}
 
 		# Commits are listed here for your convenience.
-		$(git log --format='# %h %s' "${target}..${branch}")
+		$(format_commits "${commits[@]}")
 
 		# Please leave the template below.
 		# Either fill the boxes here or via the website after pushing.