forked from paulirish/git-open
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.bats
More file actions
130 lines (106 loc) · 3.85 KB
/
github.bats
File metadata and controls
130 lines (106 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bats
load "test_helper/index"
##
## GitHub
##
@test "gh: basic" {
git remote set-url origin "git@github.com:user/repo.git"
git checkout -B "master"
run ../git-open
assert_output "https://github.com/user/repo"
}
@test "gh: branch" {
git remote set-url origin "git@github.com:user/repo.git"
git checkout -B "mybranch"
run ../git-open
assert_output "https://github.com/user/repo/tree/mybranch"
}
@test "gh: non-origin remote" {
git remote set-url origin "git@github.com:user/repo.git"
git remote add upstream "git@github.com:upstreamorg/repo.git"
run ../git-open "upstream"
assert_output "https://github.com/upstreamorg/repo"
git checkout -B "mybranch"
run ../git-open "upstream" "otherbranch"
assert_output "https://github.com/upstreamorg/repo/tree/otherbranch"
}
@test "gh: without git user" {
# https://github.com/paulirish/git-open/pull/63
git remote set-url origin "github.com:paulirish/git-open.git"
run ../git-open
assert_output "https://github.com/paulirish/git-open"
}
@test "gh: ssh origin" {
git remote set-url origin "ssh://git@github.com/user/repo"
run ../git-open
assert_output "https://github.com/user/repo"
# https://github.com/paulirish/git-open/pull/30
git remote set-url origin "ssh://git@github.com/user/repo.git"
run ../git-open
assert_output "https://github.com/user/repo"
}
@test "gh: git protocol origin" {
git remote set-url origin "git://github.com/user/repo.git"
git checkout -B "master"
run ../git-open
assert_output "https://github.com/user/repo"
}
@test "gh: git open --issue" {
# https://github.com/paulirish/git-open/pull/46
git remote set-url origin "github.com:paulirish/git-open.git"
git checkout -B "issues/#12"
run ../git-open "--issue"
assert_output "https://github.com/paulirish/git-open/issues/12"
git checkout -B "fix-issue-37"
run ../git-open "--issue"
assert_output "https://github.com/paulirish/git-open/issues/37"
git checkout -B "fix-issue-38"
run ../git-open "-i"
assert_output "https://github.com/paulirish/git-open/issues/38"
}
@test "gh: gist" {
git remote set-url origin "git@gist.github.com:2d84a6db1b41b4020685.git"
run ../git-open
assert_output "https://gist.github.com/2d84a6db1b41b4020685"
}
@test "basic: # and % in branch names are URL encoded" {
# https://github.com/paulirish/git-open/pull/24
git checkout -B "issue-#42"
run ../git-open
assert_output "https://github.com/paulirish/git-open/tree/issue-%2342"
git checkout -B "just-50%"
run ../git-open
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
remote_name="sandboxremote"
remote_url="git@github.com:userfork/git-open.git"
# ideally we'd set a real upstream branch, but that's not possible without
# pull/push'ing over the network. So we're cheating and just setting the
# branch.<branch>.remote config
# https://github.com/paulirish/git-open/pull/88#issuecomment-339813145
git remote add $remote_name $remote_url
git config --local --add branch.master.remote $remote_name
run ../git-open
assert_output "https://github.com/userfork/git-open"
git config --local --add branch.master.remote origin
run ../git-open
assert_output "https://github.com/paulirish/git-open"
}
@test "basic: https url can contain port" {
git remote set-url origin "https://github.com:99/user/repo.git"
run ../git-open
assert_output "https://github.com:99/user/repo"
}
@test "basic: ssh url has port removed from http url" {
git remote set-url origin "ssh://github.com:22/user/repo.git"
run ../git-open
assert_output "https://github.com/user/repo"
}
@test "basic: http url scheme is preserved" {
git remote set-url origin "http://github.com/user/repo.git"
run ../git-open
assert_output "http://github.com/user/repo"
}