mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 15:36:16 -04:00
default to branch's tracked remote
This commit is contained in:
parent
e68eee6a44
commit
e58004609a
7
git-open
7
git-open
|
|
@ -25,8 +25,11 @@ if [[ "$1" == 'issue' ]]; then
|
|||
shift
|
||||
fi
|
||||
|
||||
# assume remote origin if not provided
|
||||
remote=${1:-"origin"}
|
||||
# choose remote. priority to: provided argument, detected tracked remote, 'origin'
|
||||
branch_name=$(git name-rev --name-only HEAD 2>/dev/null)
|
||||
tracked_remote=$(git config "branch.$branch_name.remote")
|
||||
remote=${1:-$tracked_remote}
|
||||
remote=${remote:-"origin"}
|
||||
|
||||
# @TODO ls-remote will also expand "insteadOf" items `giturl=$(git ls-remote --get-url $remote)``
|
||||
giturl=$(git config --get "remote.${remote}.url")
|
||||
|
|
|
|||
|
|
@ -104,6 +104,24 @@ setup() {
|
|||
assert_output "https://github.com/paulirish/git-open/tree/just-50%25"
|
||||
}
|
||||
|
||||
@test "basic: tracked remote is default" {
|
||||
# https://github.com/paulirish/git-open/issues/65
|
||||
|
||||
# create a local git repo I can push to
|
||||
local_remote="sandboxremote"
|
||||
cd .. && rm -rf $local_remote && mkdir $local_remote && cd $local_remote &&
|
||||
git init --bare myrepo.git &&
|
||||
cd ../$foldername
|
||||
|
||||
git remote add other "../$local_remote/myrepo.git"
|
||||
git push --set-upstream other master
|
||||
run ../git-open
|
||||
# Not an ideal assertion, but it works..
|
||||
assert_output "https://../$local_remote/myrepo"
|
||||
|
||||
# cleanup
|
||||
rm -rf ../$local_remote
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
|
|
|
|||
Loading…
Reference in a new issue