proj/gagit:main commit in: /
MichaŠGórny <[email protected]> Wed, 05 Aug 2026 10:14:48 +0000 (UTC)
| Newsgroups | gmane.linux.gentoo.cvs |
|---|---|
| Message-ID | <1785924785.9da9b4640f888013132fef62e26fc622eb533630.mgorny@gentoo> |
commit: 9da9b4640f888013132fef62e26fc622eb533630
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 5 10:13:05 2026 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug 5 10:13:05 2026 +0000
URL: https://gitweb.gentoo.org/proj/gagit.git/commit/?id=9da9b464
Support setting title and description via options
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
gagit | 58 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 13 deletions(-)
diff --git a/gagit b/gagit
index bb9fd6c..1c1ad9c 100755
--- a/gagit
+++ b/gagit
@@ -26,16 +26,20 @@ print_help() {
echo "Create a Forgejo pull request for the current branch via AGit."
echo
echo "Options:"
+ echo " -d DESC, --description DESC"
+ echo " Set the pull request description"
echo " -e EDITOR, --editor EDITOR"
echo " Override the editor used (default: \${EDITOR})"
+ echo " -o TOPIC, --topic TOPIC"
+ echo " Specify the topic to use (default: branch name)"
echo " -r REMOTE, --remote REMOTE"
echo " Specify the Codeberg remote name"
echo " (default: search for codeberg.org SSH URL)"
echo " -T TARGET, --target TARGET"
echo " Specify the target branch"
echo " (default: first of dev, main, master on remote)"
- echo " -t TOPIC, --topic TOPIC"
- echo " Specify the topic to use (default: branch name)"
+ echo " -t TITLE, --title TITLE"
+ echo " Set the pull request title"
echo " -h, --help Print this help message"
echo " -V, --version Print the version string"
}
@@ -83,9 +87,11 @@ fj_b64() {
}
main() {
+ local description=
local editor=
local remote=
local target=
+ local title=
local topic=
while [[ ${#} -gt 0 ]]; do
@@ -98,6 +104,17 @@ main() {
echo "gagit ${VERSION}"
exit 0
;;
+ -d|--description)
+ [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
+ description=${2}
+ shift
+ ;;
+ -d*)
+ description=${1#-d}
+ ;;
+ --description=*)
+ description=${1#*=}
+ ;;
-e|--editor)
[[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
editor=${2}
@@ -131,13 +148,24 @@ main() {
--target=*)
target=${1#*=}
;;
- -t|--topic)
+ -t|--title)
[[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
- topic=${2}
+ title=${2}
shift
;;
-t*)
- topic=${1#-t}
+ title=${1#-t}
+ ;;
+ --title=*)
+ title=${1#*=}
+ ;;
+ -o|--topic)
+ [[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
+ topic=${2}
+ shift
+ ;;
+ -o*)
+ topic=${1#-o}
;;
--topic=*)
topic=${1#*=}
@@ -181,20 +209,22 @@ main() {
echo "Target branch: ${target}" >&2
local template=$(get_template)
+ : "${title:=WIP: ${topic}}"
tempdir=$(mktemp -d) || die "Unable to create a temporary directory"
trap 'rm -r -f "${tempdir}"' EXIT
cat > "${tempdir}/message" <<-EOF || die "Unable to write template"
- # Please edit this file to set the new pull request title and body.
+ # Please edit this file to set the new pull request title and description.
# All lines starting with '#' will be discarded.
# An empty description will abort creating the PR.
# ${branch} -> ${remote}/${target}
# Put a single line title below.
# "WIP:" creates a draft. Remove it to skip draft stage.
- WIP: ${topic}
+ ${title}
# Put the pull request description below.
+ ${description}
# Commits are listed here for your convenience.
$(git log --format='# %h %s' "${target}..${branch}")
@@ -205,7 +235,9 @@ main() {
EOF
${editor} "${tempdir}/message"
- local line title body nl=$'\n'
+ title=
+ description=
+ local line nl=$'\n'
{
# find the title
while read -r line; do
@@ -216,17 +248,17 @@ main() {
# no title? sounds like we got an empty file (whitespace only)
[[ -z ${title} ]] && die "No pull request description provided."
- # find the initial body line
+ # find the initial description line
while read -r line; do
[[ ${line} == '#'* || -z ${line## } ]] && continue
- body="${line}${nl}"
+ description="${line}${nl}"
break
done
- # copy the remaining body lines
+ # copy the remaining description lines
while read -r line; do
[[ ${line} == '#'* ]] && continue
- body+="${line}${nl}"
+ description+="${line}${nl}"
done
} < "${tempdir}/message"
@@ -236,7 +268,7 @@ main() {
edo git config "branch.${branch}.merge" "refs/for/${target}/${topic}"
edo git push \
-o "title=$(fj_b64 "${title}")" \
- -o "description=$(fj_b64 "${body}")"
+ -o "description=$(fj_b64 "${description}")"
echo
echo "The branch has been set to push to the PR. To update it:"