diff --git a/features/clone.feature b/features/clone.feature index 7394dcfca614717c7fe860a784ba6c215651ec1d..37aaecc1540ae6b8cd43c68314f7e391ef820f04 100644 --- a/features/clone.feature +++ b/features/clone.feature @@ -94,7 +94,7 @@ Feature: hub clone Scenario: Preview cloning a private repo 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 "git clone" should not be run + But it should not clone anything Scenario: Clone a private repo When I successfully run `hub clone -p rtomayko/ronn` @@ -137,6 +137,18 @@ Feature: hub clone Then "git clone git@github.com:sstephenson/rbenv.git" should be run And there should be no output + Scenario: Preview cloning a repo I have push access to + Given the GitHub API server: + """ + get('/repos/sstephenson/rbenv') { + json :private => false, + :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" diff --git a/features/steps.rb b/features/steps.rb index b110dd579f83f77681e1c1a5900064d4ab32a60d..d933858ede4f78c9eaf104e45b549a98268282ef 100644 --- a/features/steps.rb +++ b/features/steps.rb @@ -141,8 +141,12 @@ Then(/^it should clone "([^"]*)"$/) do |repo| step %("git clone #{repo}" should be run) end +Then(/^it should not clone anything$/) do + history.each { |h| expect(h).to_not match(/^git clone/) } +end + Then(/^"([^"]+)" should not be run$/) do |pattern| - history.all? {|h| expect(h).to_not include(pattern) } + history.each { |h| expect(h).to_not include(pattern) } end Then(/^there should be no output$/) do diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index 32df3f18d1bc9bed59f1d97acd6b057a0232540c..31a923ad8c2de070fc3d46cb709efce9acf51e1e 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -294,7 +294,7 @@ module Hub name, owner = arg, nil owner, name = name.split('/', 2) if name.index('/') project = github_project(name, owner || github_user) - unless ssh || args[0] == 'submodule' || args.noop? || https_protocol? + unless ssh || args[0] == 'submodule' || https_protocol? repo_info = api_client.repo_info(project) ssh = repo_info.success? && (repo_info.data['private'] || repo_info.data['permissions']['push']) end