Commit 9e47e11d authored by Samuel E. Giddins's avatar Samuel E. Giddins

Allow the specification of a source URL in a Podfile

parent dd70ffdd
......@@ -12,7 +12,7 @@ gemspec
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-core', 'Core', 'source-url'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
......
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: afe219baa5a4854067145825d0c141e43eee0e6a
branch: master
revision: 4189457e12113b09eafc1ebabcf1559fc23ef7b9
branch: source-url
specs:
cocoapods-core (0.34.0.rc2)
activesupport (>= 3.2.15)
......
......@@ -318,12 +318,6 @@ module Pod
def resolve_dependencies
specs_by_target = nil
UI.section "Resolving dependencies of #{UI.path podfile.defined_in_file}" do
if podfile.sources.empty?
sources = SourcesManager.master
else
sources = SourcesManager.sources(podfile.sources)
end
resolver = Resolver.new(sandbox, podfile, locked_dependencies, sources)
specs_by_target = resolver.resolve
end
......@@ -367,6 +361,27 @@ module Pod
private
# Returns the sources used to query for specifications
#
# @return [Array<Source>] the sources to be used in finding
# specifications, as specified by the {#podfile}, defaulting to
# {SourcesManager.master}
#
def sources
@sources ||= begin
sources = podfile.sources
if sources.empty?
SourcesManager.master
else
urls = sources.select { |s| s =~ /\A#{URI.regexp}\z/ }
url_sources = urls.map do |url|
SourcesManager.find_or_create_source_with_url!(url)
end
SourcesManager.sources(sources - urls) + url_sources
end
end
end
# @!group Analysis sub-steps
# Returns the path of the user project that the {TargetDefinition}
......
......@@ -23,6 +23,44 @@ module Pod
dirs.map { |repo| Source.new(repo) }
end
# Returns the source whose {Source#url} is equal to `url`, adding the repo
# in a manner similarly to `pod repo add` if it is not found.
#
# @raise If no source with the given `url` could be created,
#
# @return [Source] The source whose {Source#url} is equal to `url`,
#
# @param [String] url
# The URL of the source.
#
def find_or_create_source_with_url(url)
unless source = source_with_url(url)
name = URI(url).path.split('/')[-2]
UI.section("Cloning spec repo `#{name}` from `#{url}`") do
config.repos_dir.mkpath
Dir.chdir(config.repos_dir) do
command = "clone '#{url}' #{name}"
output = git(command)
end
check_version_information(config.repos_dir + name)
source = sources([name]).find
end
end
raise Informative, "Unable to add a source with url `#{url}`:\n\n" +
output unless source
source
end
# @return [Source] The source whose {Source#url} is equal to `url`.
#
# @param [String] url
# The URL of the source.
#
def source_with_url(url)
aggregate.sources.find { |s| s.url == url }
end
# @return [Array<Source>] The list of all the sources known to this
# installation of CocoaPods.
#
......@@ -31,7 +69,7 @@ module Pod
dirs.map { |repo| Source.new(repo) }
end
# @return [Source] The CocoaPods Master Repo source.
# @return [Array<Source>] The CocoaPods Master Repo source.
#
def master
sources(['master'])
......
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