Skip to content

Commit

Permalink
Improve detection of the target branch
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
kemenaran committed Mar 8, 2017
1 parent f499e53 commit c4042e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions git-open-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _build_url() {
repo="$(_get_repo "$origin")"
pr_url="https://github.com/$repo/pull/new"
target="$1"
test -z "$target" && target=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f 2)
test -z "$target" && target="master"
if [ -z "$upstream" ]; then
echo "$pr_url/$target...$branch"
Expand Down

0 comments on commit c4042e2

Please sign in to comment.