File tree Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,17 @@ git open issue
18
18
19
19
``` sh
20
20
$ git open
21
- # opens https://github.com/REMOTE_ORIGIN_USER /CURRENT_REPO/tree/CURRENT_BRANCH
21
+ # opens https://github.com/TRACKED_REMOTE_USER /CURRENT_REPO/tree/CURRENT_BRANCH
22
22
23
- $ git open upstream
24
- # opens https://github.com/REMOTE_UPSTREAM_USER /CURRENT_REPO/tree/CURRENT_BRANCH
23
+ $ git open someremote
24
+ # opens https://github.com/PROVIDED_REMOTE_USER /CURRENT_REPO/tree/CURRENT_BRANCH
25
25
26
- $ git open upstream master
27
- # opens https://github.com/REMOTE_UPSTREAM_USER /CURRENT_REPO/tree/master
26
+ $ git open someremote somebranch
27
+ # opens https://github.com/PROVIDED_REMOTE_USER /CURRENT_REPO/tree/PROVIDED_BRANCH
28
28
29
29
$ git open issue
30
30
# If branches use naming convention of issues/#123,
31
- # opens https://github.com/REMOTE_UPSTREAM_USER /CURRENT_REPO/issues/123
31
+ # opens https://github.com/TRACKED_REMOTE_USER /CURRENT_REPO/issues/123
32
32
```
33
33
34
34
## Installation
Original file line number Diff line number Diff line change @@ -25,8 +25,11 @@ if [[ "$1" == 'issue' ]]; then
25
25
shift
26
26
fi
27
27
28
- # assume remote origin if not provided
29
- remote=${1:- " origin" }
28
+ # choose remote. priority to: provided argument, detected tracked remote, 'origin'
29
+ branch_name=$( git name-rev --name-only HEAD 2> /dev/null)
30
+ tracked_remote=$( git config " branch.$branch_name .remote" )
31
+ remote=${1:- $tracked_remote }
32
+ remote=${remote:- " origin" }
30
33
31
34
# @TODO ls-remote will also expand "insteadOf" items `giturl=$(git ls-remote --get-url $remote)``
32
35
giturl=$( git config --get " remote.${remote} .url" )
Original file line number Diff line number Diff line change @@ -104,6 +104,27 @@ setup() {
104
104
assert_output " https://github.com/paulirish/git-open/tree/just-50%25"
105
105
}
106
106
107
+ @test " basic: tracked remote is default" {
108
+ # https://github.com/paulirish/git-open/issues/65
109
+
110
+ # create a local git repo I can push to
111
+ remote_name=" sandboxremote"
112
+ remote_url=
" [email protected] :userfork/git-open.git"
113
+
114
+ # ideally we'd set a real upstream branch, but that's not possible without
115
+ # pull/push'ing over the network. So we're cheating and just setting the
116
+ # branch.<branch>.remote config
117
+ # https://github.com/paulirish/git-open/pull/88#issuecomment-339813145
118
+ git remote add $remote_name $remote_url
119
+ git config --local --add branch.master.remote $remote_name
120
+
121
+ run ../git-open
122
+ assert_output " https://github.com/userfork/git-open"
123
+
124
+ git config --local --add branch.master.remote origin
125
+ run ../git-open
126
+ assert_output " https://github.com/paulirish/git-open"
127
+ }
107
128
108
129
109
130
# #
You can’t perform that action at this time.
0 commit comments