Skip to content

Check cloned repo with using ghq #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/rubygems_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,27 @@ def use_ghq?
ENV['GEMSRC_USE_GHQ'] || Gem.configuration[:gemsrc_use_ghq]
end

def cloned?
if use_ghq?
candidates = [
installer.spec.homepage,
github_url(installer.spec.homepage),
source_code_uri,
homepage_uri,
github_url(homepage_uri),
github_organization_uri(installer.spec.name)
].compact.map do |uri|
uri.gsub(%r|https?://|, '')
end
cloned_repos = `ghq list`.split
!(cloned_repos & candidates).empty?
else
File.exist? clone_dir
end
end

def git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
return false if File.exist? clone_dir
return false if cloned?
git_clone(installer.spec.homepage) ||
git_clone(github_url(installer.spec.homepage)) ||
git_clone(source_code_uri) ||
Expand Down