proj/gagit:main commit in: /

Michał Górny <[email protected]> Mon, 03 Aug 2026 13:59:39 +0000 (UTC)
Newsgroups gmane.linux.gentoo.cvs
Message-ID <1785765566.d5d30b3c876f00365c61c8873de1f55023723331.mgorny@gentoo>
commit:     d5d30b3c876f00365c61c8873de1f55023723331
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  3 13:58:58 2026 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 13:59:26 2026 +0000
URL:        https://gitweb.gentoo.org/proj/gagit.git/commit/?id=d5d30b3c

Implement finding the target branch

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

 gagit | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gagit b/gagit
index 96042fa..0cb5066 100755
--- a/gagit
+++ b/gagit
@@ -47,8 +47,14 @@ find_remote() {
 }
 
 find_target_branch() {
-	# TODO
-	echo main
+	local remote=${1}
+	local candidate
+	for candidate in dev main master; do
+		if git rev-parse "${remote}/${candidate}" &>/dev/null; then
+			echo "${candidate}"
+			return
+		fi
+	done
 }
 
 get_template() {
@@ -123,7 +129,8 @@ main() {
 	# TODO: should we allow a different topic?
 	local topic=${branch}
 
-	local target=$(find_target_branch)
+	local target=$(find_target_branch "${remote}")
+	[[ -z ${remote} ]] && die "Unable to find a target branch"
 	echo "Target branch: ${target}" >&2
 
 	local template=$(get_template)