Skip to content

Commit c4042e2

Browse files
committed
Improve detection of the target branch
If the target branch isn't specified in the command arguments, attempts to find the name of the remotly tracked branch (before falling back on `master`). This means that if the branch `feature` tracks `upstream/dev`, the code will correctly detect that the target branch is `dev`.
1 parent f499e53 commit c4042e2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

git-open-pr.sh

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _build_url() {
1212
repo="$(_get_repo "$origin")"
1313
pr_url="https://github.com/$repo/pull/new"
1414
target="$1"
15+
test -z "$target" && target=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f 2)
1516
test -z "$target" && target="master"
1617
if [ -z "$upstream" ]; then
1718
echo "$pr_url/$target...$branch"

0 commit comments

Comments
 (0)