|
1 | 1 | require 'fileutils'
|
2 | 2 |
|
3 | 3 | Given(/^HTTPS is preferred$/) do
|
4 |
| - run_command_and_stop %(git config --global hub.protocol https) |
| 4 | + run_ignored_command %(git config --global hub.protocol https) |
5 | 5 | end
|
6 | 6 |
|
7 | 7 | Given(/^there are no remotes$/) do
|
8 |
| - run_command_and_stop 'git remote' |
9 |
| - expect(last_command_started).not_to have_output |
| 8 | + output = run_ignored_command 'git remote' |
| 9 | + expect(output).to be_empty |
10 | 10 | end
|
11 | 11 |
|
12 | 12 | Given(/^"([^"]*)" is a whitelisted Enterprise host$/) do |host|
|
13 |
| - run_command_and_stop %(git config --global --add hub.host "#{host}") |
| 13 | + run_ignored_command %(git config --global --add hub.host "#{host}") |
14 | 14 | end
|
15 | 15 |
|
16 | 16 | Given(/^git "(.+?)" is set to "(.+?)"$/) do |key, value|
|
17 |
| - run_command_and_stop %(git config #{key} "#{value}") |
| 17 | + run_ignored_command %(git config #{key} "#{value}") |
18 | 18 | end
|
19 | 19 |
|
20 | 20 | Given(/^the "([^"]*)" remote has(?: (push))? url "([^"]*)"$/) do |remote_name, push, url|
|
21 |
| - run_command_and_stop 'git remote' |
22 |
| - unless last_command_started.stdout.split("\n").include? remote_name |
23 |
| - run_command_and_stop %(git remote add #{remote_name} "#{url}") |
| 21 | + remotes = run_ignored_command 'git remote' |
| 22 | + unless remotes.split("\n").include? remote_name |
| 23 | + run_ignored_command %(git remote add #{remote_name} "#{url}") |
24 | 24 | else
|
25 |
| - run_command_and_stop %(git remote set-url #{"--push" if push} #{remote_name} "#{url}") |
| 25 | + run_ignored_command %(git remote set-url #{"--push" if push} #{remote_name} "#{url}") |
26 | 26 | end
|
27 | 27 | end
|
28 | 28 |
|
|
52 | 52 | end
|
53 | 53 |
|
54 | 54 | Given(/^a (bare )?git repo in "([^"]*)"$/) do |bare, dir_name|
|
55 |
| - run_command_and_stop %(git init --quiet #{"--bare" if bare} '#{dir_name}') |
| 55 | + run_ignored_command %(git init --quiet #{"--bare" if bare} '#{dir_name}') |
56 | 56 | end
|
57 | 57 |
|
58 | 58 | Given(/^a git bundle named "([^"]*)"$/) do |file|
|
|
71 | 71 | Given(/^there is a commit named "([^"]+)"$/) do |name|
|
72 | 72 | empty_commit
|
73 | 73 | empty_commit
|
74 |
| - run_command_and_stop %(git tag #{name}) |
75 |
| - run_command_and_stop %(git reset --quiet --hard HEAD^) |
| 74 | + run_ignored_command %(git tag #{name}) |
| 75 | + run_ignored_command %(git reset --quiet --hard HEAD^) |
76 | 76 | end
|
77 | 77 |
|
78 | 78 | Given(/^there is a git FETCH_HEAD$/) do
|
|
83 | 83 | fetch_head.puts "%s\t\t'refs/heads/made-up' of git://github.com/made/up.git" % `git rev-parse HEAD`.chomp
|
84 | 84 | end
|
85 | 85 | end
|
86 |
| - run_command_and_stop %(git reset --quiet --hard HEAD^) |
| 86 | + run_ignored_command %(git reset --quiet --hard HEAD^) |
87 | 87 | end
|
88 | 88 |
|
89 | 89 | When(/^I make (a|\d+) commits?(?: with message "([^"]+)")?$/) do |num, msg|
|
|
114 | 114 | end
|
115 | 115 |
|
116 | 116 | Given(/^I am on the "([^"]+)" branch(?: (pushed to|with upstream) "([^"]+)")?$/) do |name, type, upstream|
|
117 |
| - run_command_and_stop %(git checkout --quiet -b #{shell_escape name}) |
| 117 | + run_ignored_command %(git checkout --quiet -b #{shell_escape name}) |
118 | 118 | empty_commit
|
119 | 119 |
|
120 | 120 | if upstream
|
121 | 121 | full_upstream = upstream.start_with?('refs/') ? upstream : "refs/remotes/#{upstream}"
|
122 |
| - run_command_and_stop %(git update-ref #{shell_escape full_upstream} HEAD) |
| 122 | + run_ignored_command %(git update-ref #{shell_escape full_upstream} HEAD) |
123 | 123 |
|
124 | 124 | if type == 'with upstream'
|
125 |
| - run_command_and_stop %(git branch --set-upstream-to #{shell_escape upstream}) |
| 125 | + run_ignored_command %(git branch --set-upstream-to #{shell_escape upstream}) |
126 | 126 | end
|
127 | 127 | end
|
128 | 128 | end
|
|
136 | 136 | FileUtils.cp '.git/refs/heads/master', ref_file
|
137 | 137 | end
|
138 | 138 | end
|
139 |
| - run_command_and_stop %(git remote set-head #{remote} #{branch}) |
| 139 | + run_ignored_command %(git remote set-head #{remote} #{branch}) |
140 | 140 | end
|
141 | 141 |
|
142 | 142 | Given(/^I am in detached HEAD$/) do
|
143 | 143 | empty_commit
|
144 | 144 | empty_commit
|
145 |
| - run_command_and_stop %(git checkout HEAD^) |
| 145 | + run_ignored_command %(git checkout HEAD^) |
146 | 146 | end
|
147 | 147 |
|
148 | 148 | Given(/^the current dir is not a repo$/) do
|
|
185 | 185 | end
|
186 | 186 |
|
187 | 187 | Then(/^the url for "([^"]*)" should be "([^"]*)"$/) do |name, url|
|
188 |
| - run_command_and_stop %(git config --get-all remote.#{name}.url) |
189 |
| - expect(last_command_started).to have_output(url) |
| 188 | + output = run_ignored_command %(git config --get-all remote.#{name}.url) |
| 189 | + expect(output).to include(url) |
190 | 190 | end
|
191 | 191 |
|
192 | 192 | Then(/^the "([^"]*)" submodule url should be "([^"]*)"$/) do |name, url|
|
193 |
| - run_command_and_stop %(git config --get-all submodule."#{name}".url) |
194 |
| - expect(last_command_started).to have_output(url) |
| 193 | + output = run_ignored_command %(git config --get-all submodule."#{name}".url) |
| 194 | + expect(output).to include(url) |
195 | 195 | end
|
196 | 196 |
|
197 | 197 | Then(/^"([^"]*)" should merge "([^"]*)" from remote "([^"]*)"$/) do |name, merge, remote|
|
198 |
| - run_command_and_stop %(git config --get-all branch.#{name}.remote) |
199 |
| - expect(last_command_started).to have_output(remote) |
| 198 | + output = run_ignored_command %(git config --get-all branch.#{name}.remote) |
| 199 | + expect(output).to include(remote) |
200 | 200 |
|
201 |
| - run_command_and_stop %(git config --get-all branch.#{name}.merge) |
202 |
| - expect(last_command_started).to have_output(merge) |
| 201 | + output = run_ignored_command %(git config --get-all branch.#{name}.merge) |
| 202 | + expect(output).to include(merge) |
203 | 203 | end
|
204 | 204 |
|
205 | 205 | Then(/^there should be no "([^"]*)" remote$/) do |remote_name|
|
206 |
| - run_command_and_stop 'git remote' |
207 |
| - expect(last_command_started.output.split("\n")).to_not include(remote_name) |
| 206 | + remotes = run_ignored_command 'git remote' |
| 207 | + expect(remotes.split("\n")).to_not include(remote_name) |
208 | 208 | end
|
209 | 209 |
|
210 | 210 | Then(/^the file "([^"]*)" should have mode "([^"]*)"$/) do |file, expected_mode|
|
|
216 | 216 | if ref == 'HEAD'
|
217 | 217 | empty_commit
|
218 | 218 | end
|
219 |
| - run_command_and_stop %(git rev-parse #{ref}) |
220 |
| - rev = last_command_started.output.chomp |
| 219 | + output = run_ignored_command %(git rev-parse #{ref}) |
| 220 | + rev = output.chomp |
221 | 221 |
|
222 | 222 | host, owner, repo = proj.split('/', 3)
|
223 | 223 | if repo.nil?
|
|
0 commit comments