Commit 06d11ca5 authored by Fabio Pelosin's avatar Fabio Pelosin

Remove Octokit dep 2

Closes #1080
parent 8412b230
...@@ -32,15 +32,6 @@ module Pod ...@@ -32,15 +32,6 @@ module Pod
def run def run
if repo_id_match = (@url || @name_or_url).match(/github.com\/([^\/\.]*\/[^\/\.]*)\.*/) if repo_id_match = (@url || @name_or_url).match(/github.com\/([^\/\.]*\/[^\/\.]*)\.*/)
# This is to make sure Faraday doesn't warn the user about the `system_timer` gem missing.
old_warn, $-w = $-w, nil
begin
require 'faraday'
ensure
$-w = old_warn
end
require 'octokit'
repo_id = repo_id_match[1] repo_id = repo_id_match[1]
data = github_data_for_template(repo_id) data = github_data_for_template(repo_id)
data[:name] = @name_or_url if @url data[:name] = @name_or_url if @url
...@@ -410,8 +401,8 @@ module Pod ...@@ -410,8 +401,8 @@ module Pod
end end
def github_data_for_template(repo_id) def github_data_for_template(repo_id)
repo = Octokit.repo(repo_id) repo = GitHub.repo(repo_id)
user = Octokit.user(repo['owner']['login']) user = GitHub.user(repo['owner']['login'])
data = {} data = {}
data[:name] = repo['name'] data[:name] = repo['name']
...@@ -425,7 +416,7 @@ module Pod ...@@ -425,7 +416,7 @@ module Pod
end end
def suggested_ref_and_version(repo) def suggested_ref_and_version(repo)
tags = Octokit.tags(:username => repo['owner']['login'], :repo => repo['name']).map {|tag| tag["name"]} tags = GitHub.tags(repo['html_url']).map {|tag| tag["name"]}
versions_tags = {} versions_tags = {}
tags.each do |tag| tags.each do |tag|
clean_tag = tag.gsub(/^v(er)? ?/,'') clean_tag = tag.gsub(/^v(er)? ?/,'')
...@@ -434,9 +425,9 @@ module Pod ...@@ -434,9 +425,9 @@ module Pod
version = versions_tags.keys.sort.last || '0.0.1' version = versions_tags.keys.sort.last || '0.0.1'
data = {:version => version} data = {:version => version}
if version == '0.0.1' if version == '0.0.1'
branches = Octokit.branches(:username => repo['owner']['login'], :repo => repo['name']) branches = GitHub.branches(repo['html_url'])
master_name = repo['master_branch'] || 'master' master_name = repo['master_branch'] || 'master'
master = branches.select {|branch| branch['name'] == master_name }.first master = branches.find {|branch| branch['name'] == master_name }
data[:ref_type] = ':commit' data[:ref_type] = ':commit'
data[:ref] = master['commit']['sha'] data[:ref] = master['commit']['sha']
else else
......
...@@ -40,42 +40,58 @@ module Pod ...@@ -40,42 +40,58 @@ module Pod
end end
it "correctly creates a podspec from github" do it "correctly creates a podspec from github" do
expect_github_repo_request repo = {
expect_github_user_request 'name' => 'libPusher',
expect_github_tags_request 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git'
}
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"v1.4"}])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" })
run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'libPusher.podspec' path = temporary_directory + 'libPusher.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
spec.name.should == 'libPusher' spec.name.should == 'libPusher'
spec.license.should == { :type => "MIT (example)" } spec.license.should == { :type => "MIT (example)" }
spec.version.should == Version.new('1.3') spec.version.should == Version.new('1.4')
spec.summary.should == 'An Objective-C interface to Pusher (pusherapp.com)' spec.summary.should == 'An Objective-C interface to Pusher (pusherapp.com)'
spec.homepage.should == 'https://github.com/lukeredpath/libPusher' spec.homepage.should == 'https://github.com/lukeredpath/libPusher'
spec.authors.should == {"Luke Redpath"=>"luke@lukeredpath.co.uk"} spec.authors.should == {"Luke Redpath"=>"luke@lukeredpath.co.uk"}
spec.source.should == { :git => 'https://github.com/lukeredpath/libPusher.git', :tag => 'v1.3' } spec.source.should == { :git => 'https://github.com/lukeredpath/libPusher.git', :tag => 'v1.4' }
end end
it "accepts a name when creating a podspec form github" do it "accepts a name when creating a podspec form github" do
expect_github_repo_request repo = {
expect_github_user_request 'name' => 'libPusher',
expect_github_tags_request 'owner' => { 'login' => 'lukeredpath' },
'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git'
}
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"v1.4"}])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" })
run_command('spec', 'create', 'other_name', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'other_name', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'other_name.podspec' path = temporary_directory + 'other_name.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
spec.name.should == 'other_name' spec.name.should == 'other_name'
spec.license.should == { :type => "MIT (example)" }
spec.version.should == Version.new('1.3')
spec.summary.should == 'An Objective-C interface to Pusher (pusherapp.com)'
spec.homepage.should == 'https://github.com/lukeredpath/libPusher' spec.homepage.should == 'https://github.com/lukeredpath/libPusher'
spec.authors.should == {"Luke Redpath"=>"luke@lukeredpath.co.uk"}
spec.source.should == { :git => 'https://github.com/lukeredpath/libPusher.git', :tag => 'v1.3' }
end end
it "correctly suggests the head commit if a suitable tag is not available on github" do it "correctly suggests the head commit if a suitable tag is not available on github" do
expect_github_repo_request repo = {
expect_github_user_request 'name' => 'libPusher',
expect_github_tags_request([{"name" => "experiment"}]) 'owner' => { 'login' => 'lukeredpath' },
expect_github_branches_request 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git'
}
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"experiment"}])
GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"master", "commit" => {'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7'}}])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" })
run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
path = temporary_directory + 'libPusher.podspec' path = temporary_directory + 'libPusher.podspec'
spec = Specification.from_file(path) spec = Specification.from_file(path)
...@@ -84,10 +100,17 @@ module Pod ...@@ -84,10 +100,17 @@ module Pod
end end
it "provides a markdown template if a github repo doesn't have semantic version tags" do it "provides a markdown template if a github repo doesn't have semantic version tags" do
expect_github_repo_request repo = {
expect_github_user_request 'name' => 'libPusher',
expect_github_tags_request([{"name" => "experiment"}]) 'owner' => { 'login' => 'lukeredpath' },
expect_github_branches_request 'html_url' => 'https://github.com/lukeredpath/libPusher',
'description' => 'An Objective-C interface to Pusher (pusherapp.com)',
'clone_url' => 'https://github.com/lukeredpath/libPusher.git'
}
GitHub.expects(:repo).with('lukeredpath/libPusher').returns(repo)
GitHub.expects(:tags).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"experiment"}])
GitHub.expects(:branches).with('https://github.com/lukeredpath/libPusher').returns([{"name"=>"master", "commit" => {'sha' => '5f482b0693ac2ac1ad85d1aabc27ec7547cc0bc7'}}])
GitHub.expects(:user).with('lukeredpath').returns({ "name" => "Luke Redpath", "email" => "luke@lukeredpath.co.uk" })
output = run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git') output = run_command('spec', 'create', 'https://github.com/lukeredpath/libPusher.git')
output.should.include 'MARKDOWN TEMPLATE' output.should.include 'MARKDOWN TEMPLATE'
output.should.include 'Please add semantic version tags' output.should.include 'Please add semantic version tags'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment