forked from mislav/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone.feature
More file actions
288 lines (261 loc) · 10.4 KB
/
Copy pathclone.feature
File metadata and controls
288 lines (261 loc) · 10.4 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
Feature: hub clone
Background:
Given I am "mislav" on github.com with OAuth token "OTOKEN"
Scenario: Clone a public repo
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone rtomayko/ronn`
Then it should clone "git://github.com/rtomayko/ronn.git"
And the output should not contain anything
Scenario: Clone a public repo with period in name
Given the GitHub API server:
"""
get('/repos/hookio/hook.js') {
json :private => false,
:name => 'hook.js', :owner => { :login => 'hookio' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone hookio/hook.js`
Then it should clone "git://github.com/hookio/hook.js.git"
And the output should not contain anything
Scenario: Clone a public repo that starts with a period
Given the GitHub API server:
"""
get('/repos/zhuangya/.vim') {
json :private => false,
:name => '.vim', :owner => { :login => 'zhuangya' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone zhuangya/.vim`
Then it should clone "git://github.com/zhuangya/.vim.git"
And the output should not contain anything
Scenario: Clone a repo even if same-named directory exists
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
And a directory named "rtomayko/ronn"
When I successfully run `hub clone rtomayko/ronn`
Then it should clone "git://github.com/rtomayko/ronn.git"
And the output should not contain anything
Scenario: Clone a public repo with HTTPS
Given HTTPS is preferred
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone rtomayko/ronn`
Then it should clone "https://github.com/rtomayko/ronn.git"
And the output should not contain anything
Scenario: Clone command aliased
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `git config --global alias.c "clone --bare"`
And I successfully run `hub c rtomayko/ronn`
Then "git clone --bare git://github.com/rtomayko/ronn.git" should be run
And the output should not contain anything
Scenario: Unchanged public clone
When I successfully run `hub clone git://github.com/rtomayko/ronn.git`
Then the git command should be unchanged
Scenario: Unchanged public clone with path
When I successfully run `hub clone git://github.com/rtomayko/ronn.git ronnie`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged private clone
When I successfully run `hub clone git@github.com:rtomayko/ronn.git`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged clone with complex arguments
When I successfully run `hub clone --template=one/two git://github.com/defunkt/resque.git --origin master resquetastic`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged local clone
When I successfully run `hub clone ./dotfiles`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged local clone with destination
Given a directory named ".git"
When I successfully run `hub clone -l . ../copy`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged local clone from bare repo
Given a bare git repo in "rtomayko/ronn"
When I successfully run `hub clone rtomayko/ronn`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Unchanged clone with host alias
When I successfully run `hub clone shortcut:git/repo.git`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Preview cloning a private repo
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `hub --noop clone -p rtomayko/ronn`
Then the output should contain exactly "git clone git@github.com:rtomayko/ronn.git\n"
But it should not clone anything
Scenario: Clone a private repo
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronn', :owner => { :login => 'rtomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone -p rtomayko/ronn`
Then it should clone "git@github.com:rtomayko/ronn.git"
And the output should not contain anything
Scenario: Clone my repo
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
json :private => false,
:name => 'dotfiles', :owner => { :login => 'mislav' },
:permissions => { :push => true }
}
"""
When I successfully run `hub clone dotfiles`
Then it should clone "git@github.com:mislav/dotfiles.git"
And the output should not contain anything
Scenario: Clone my repo that doesn't exist
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { status 404 }
"""
When I run `hub clone dotfiles`
Then the exit status should be 1
And the stdout should contain exactly ""
And the stderr should contain exactly "Error: repository mislav/dotfiles doesn't exist\n"
And it should not clone anything
Scenario: Clone my repo with arguments
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
json :private => false,
:name => 'dotfiles', :owner => { :login => 'mislav' },
:permissions => { :push => true }
}
"""
When I successfully run `hub clone --bare -o master dotfiles`
Then "git clone --bare -o master git@github.com:mislav/dotfiles.git" should be run
And the output should not contain anything
Scenario: Clone repo to which I have push access to
Given the GitHub API server:
"""
get('/repos/sstephenson/rbenv') {
json :private => false,
:name => 'rbenv', :owner => { :login => 'sstephenson' },
:permissions => { :push => true }
}
"""
When I successfully run `hub clone sstephenson/rbenv`
Then "git clone git@github.com:sstephenson/rbenv.git" should be run
And the output should not contain anything
Scenario: Preview cloning a repo I have push access to
Given the GitHub API server:
"""
get('/repos/sstephenson/rbenv') {
json :private => false,
:name => 'rbenv', :owner => { :login => 'sstephenson' },
:permissions => { :push => true }
}
"""
When I successfully run `hub --noop clone sstephenson/rbenv`
Then the output should contain exactly "git clone git@github.com:sstephenson/rbenv.git\n"
But it should not clone anything
Scenario: Clone my Enterprise repo
Given I am "mifi" on git.my.org with OAuth token "FITOKEN"
And $GITHUB_HOST is "git.my.org"
Given the GitHub API server:
"""
get('/api/v3/repos/myorg/myrepo') {
json :private => true,
:name => 'myrepo', :owner => { :login => 'myorg' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone myorg/myrepo`
Then it should clone "git@git.my.org:myorg/myrepo.git"
And the output should not contain anything
Scenario: Clone from existing directory is a local clone
Given a directory named "dotfiles/.git"
When I successfully run `hub clone dotfiles`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Clone from git bundle is a local clone
Given a git bundle named "my-bundle"
When I successfully run `hub clone my-bundle`
Then the git command should be unchanged
And the output should not contain anything
Scenario: Clone a wiki
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronin', :owner => { :login => 'RTomayko' },
:permissions => { :push => false },
:has_wiki => true
}
"""
When I successfully run `hub clone rtomayko/ronn.wiki`
Then it should clone "git://github.com/RTomayko/ronin.wiki.git"
And the output should not contain anything
Scenario: Clone a nonexisting wiki
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
json :private => false,
:name => 'ronin', :owner => { :login => 'RTomayko' },
:permissions => { :push => false },
:has_wiki => false
}
"""
When I run `hub clone rtomayko/ronn.wiki`
Then the exit status should be 1
And the stdout should contain exactly ""
And the stderr should contain exactly "Error: RTomayko/ronin doesn't have a wiki\n"
And it should not clone anything
Scenario: Clone a redirected repo
Given the GitHub API server:
"""
get('/repos/rtomayko/ronn') {
redirect 'https://api.github.com/repositories/12345', 301
}
get('/repositories/12345', :host_name => 'api.github.com') {
halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token OTOKEN'
json :private => false,
:name => 'ronin', :owner => { :login => 'RTomayko' },
:permissions => { :push => false }
}
"""
When I successfully run `hub clone rtomayko/ronn`
Then it should clone "git://github.com/RTomayko/ronin.git"
And the output should not contain anything