Commit 198e3d04 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #3386 from CocoaPods/kylef/repo-list

[pod repo list] Fix issue showing the URL for git
parents 2fcf6c17 3a0c01c1
...@@ -13,12 +13,19 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -13,12 +13,19 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Marius Rackwitz](https://github.com/mrackwitz) [Marius Rackwitz](https://github.com/mrackwitz)
[#3145](https://github.com/CocoaPods/CocoaPods/issues/3145) [#3145](https://github.com/CocoaPods/CocoaPods/issues/3145)
* Show the source URI for local Pod specification repositories in
`pod repo list`.
[Kyle Fuller](https://github.com/kylef)
##### Bug Fixes ##### Bug Fixes
* Do not pass code-sign arguments to xcodebuild when linting OS X targets. * Do not pass code-sign arguments to xcodebuild when linting OS X targets.
[Boris Bügling](https://github.com/neonichu) [Boris Bügling](https://github.com/neonichu)
[#3310](https://github.com/CocoaPods/CocoaPods/issues/3310) [#3310](https://github.com/CocoaPods/CocoaPods/issues/3310)
* Fixes an issue showing the URL to remote resources in `pod repo list`.
[Kyle Fuller](https://github.com/kylef)
## 0.36.3 ## 0.36.3
......
...@@ -24,37 +24,6 @@ module Pod ...@@ -24,37 +24,6 @@ module Pod
def dir def dir
config.repos_dir + @name config.repos_dir + @name
end end
# Returns the branch name (i.e. master).
#
# @return [String] The name of the current branch.
#
def branch_name
`git name-rev --name-only HEAD`.strip
end
# Returns the branch remote name (i.e. origin).
#
# @param [#to_s] branch_name
# The branch name to look for the remote name.
#
# @return [String] The given branch's remote name.
#
def branch_remote_name(branch_name)
`git config branch.#{branch_name}.remote`.strip
end
# Returns the url of the given remote name
# (i.e. git@github.com:CocoaPods/Specs.git).
#
# @param [#to_s] remote_name
# The branch remote name to look for the url.
#
# @return [String] The URL of the given remote.
#
def url_of_git_repo(remote_name)
`git config remote.#{remote_name}.url`.strip
end
end end
end end
end end
...@@ -20,12 +20,13 @@ module Pod ...@@ -20,12 +20,13 @@ module Pod
# @output Examples: # @output Examples:
# #
# master # master
# - type: git (origin) # - type: git (master)
# - URL: https://github.com/CocoaPods/Specs.git # - URL: https://github.com/CocoaPods/Specs.git
# - path: /Users/lascorbe/.cocoapods/repos/master # - path: /Users/lascorbe/.cocoapods/repos/master
# #
# test # test
# - type: local copy # - type: local copy
# - URL: file:///Users/lascorbe/.cocoapods/repos/test
# - path: /Users/lascorbe/.cocoapods/repos/test # - path: /Users/lascorbe/.cocoapods/repos/test
# #
def run def run
...@@ -38,27 +39,24 @@ module Pod ...@@ -38,27 +39,24 @@ module Pod
# Pretty-prints the source at the given path. # Pretty-prints the source at the given path.
# #
# @param [String,Pathname] path # @param [Source] source
# The path of the source to be printed. # The source repository to be printed.
# #
# @return [void] # @return [void]
# #
def print_source_at_path(path) def print_source(source)
Dir.chdir(path) do if SourcesManager.git_repo?(source.repo)
if SourcesManager.git_repo?(path) Dir.chdir(source.repo) do
remote_name = branch_remote_name(branch_name) branch_name = `git name-rev --name-only HEAD 2>/dev/null`.strip
if remote_name branch_name = 'unknown' if branch_name.empty?
UI.puts "- Type: git (#{remote_name})" UI.puts "- Type: git (#{branch_name})"
url = url_of_git_repo(remote_name)
UI.puts "- URL: #{url}"
else
UI.puts '- Type: git (no remote information available)'
end end
else else
UI.puts '- Type: local copy' UI.puts '- Type: local'
end
UI.puts "- Path: #{path}"
end end
UI.puts "- URL: #{source.url}"
UI.puts "- Path: #{source.repo}"
end end
# Pretty-prints the given sources. # Pretty-prints the given sources.
...@@ -71,7 +69,7 @@ module Pod ...@@ -71,7 +69,7 @@ module Pod
def print_sources(sources) def print_sources(sources)
sources.each do |source| sources.each do |source|
UI.title source.name do UI.title source.name do
print_source_at_path source.repo print_source(source)
end end
end end
UI.puts "\n" UI.puts "\n"
......
...@@ -26,5 +26,43 @@ module Pod ...@@ -26,5 +26,43 @@ module Pod
output.should.include? 'repo' output.should.include? 'repo'
output.should.not.include? '- Type:' output.should.not.include? '- Type:'
end end
it 'shows the path to the spec repository' do
output = run_command('repo', 'list')
output.should.include? "- Path: #{repo_path('master')}"
end
it 'shows unknown as the branch when there is no branch for git repositories' do
path = repo_path(name)
path.mkpath
Dir.chdir(path) do
`git init`
end
output = run_command('repo', 'list')
output.should.include? 'git (unknown)'
end
describe 'with a git based spec repository with a remote' do
extend SpecHelper::TemporaryRepos
before do
config.repos_dir = tmp_repos_path
Dir.chdir(repo_make('apiary')) do
`git remote add origin https://github.com/apiaryio/Specs`
end
end
it 'shows the current git branch configuration' do
output = run_command('repo', 'list')
output.should.include? '- Type: git (master)'
end
it 'shows the git URL (when an upstream is not configured)' do
output = run_command('repo', 'list')
output.should.include? '- URL: https://github.com/apiaryio/Specs'
end
end
end end
end end
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