From b14337569c6434b11a40f1226cace7804d18cfcd Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Tue, 15 Jul 2014 16:55:24 +0200 Subject: [PATCH] same logic when clone --noop private repos. Fixes #593 --- features/clone.feature | 12 ++++++++++++ lib/hub/commands.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/features/clone.feature b/features/clone.feature index 7394dcfc..2a5d0aa0 100644 --- a/features/clone.feature +++ b/features/clone.feature @@ -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 "git clone" should not be run + 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/lib/hub/commands.rb b/lib/hub/commands.rb index 32df3f18..31a923ad 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