mirror of
https://github.com/zhigang1992/CocoaPods.git
synced 2026-04-29 09:55:38 +08:00
Merge pull request #750 from dcutting/master
Added support for pre-download over Mercurial.
This commit is contained in:
@@ -136,6 +136,8 @@ module Pod
|
||||
return unless name && params
|
||||
if params.key?(:git)
|
||||
GitSource.new(name, params)
|
||||
elsif params.key?(:hg)
|
||||
MercurialSource.new(name, params)
|
||||
elsif params.key?(:svn)
|
||||
SvnSource.new(name, params)
|
||||
elsif params.key?(:podspec)
|
||||
@@ -193,7 +195,7 @@ module Pod
|
||||
end
|
||||
end
|
||||
|
||||
class GitSource < AbstractExternalSource
|
||||
class DownloaderSource < AbstractExternalSource
|
||||
def copy_external_source_into_sandbox(sandbox, platform)
|
||||
UI.info("->".green + " Pre-downloading: '#{name}'") do
|
||||
target = sandbox.root + name
|
||||
@@ -206,7 +208,9 @@ module Pod
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class GitSource < DownloaderSource
|
||||
def description
|
||||
"from `#{@params[:git]}'".tap do |description|
|
||||
description << ", commit `#{@params[:commit]}'" if @params[:commit]
|
||||
@@ -216,20 +220,15 @@ module Pod
|
||||
end
|
||||
end
|
||||
|
||||
class SvnSource < AbstractExternalSource
|
||||
def copy_external_source_into_sandbox(sandbox, platform)
|
||||
UI.info("->".green + " Pre-downloading: '#{name}'") do
|
||||
target = sandbox.root + name
|
||||
target.rmtree if target.exist?
|
||||
downloader = Downloader.for_target(sandbox.root + name, @params)
|
||||
downloader.download
|
||||
store_podspec(sandbox, target + "#{name}.podspec")
|
||||
if local_pod = sandbox.installed_pod_named(name, platform)
|
||||
local_pod.downloaded = true
|
||||
end
|
||||
class MercurialSource < DownloaderSource
|
||||
def description
|
||||
"from `#{@params[:hg]}'".tap do |description|
|
||||
description << ", revision `#{@params[:revision]}'" if @params[:revision]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class SvnSource < DownloaderSource
|
||||
def description
|
||||
"from `#{@params[:svn]}'".tap do |description|
|
||||
description << ", folder `#{@params[:folder]}'" if @params[:folder]
|
||||
|
||||
BIN
spec/fixtures/mercurial-repo/.hg/dirstate
vendored
BIN
spec/fixtures/mercurial-repo/.hg/dirstate
vendored
Binary file not shown.
@@ -1 +1 @@
|
||||
Second commit
|
||||
Removed comments.
|
||||
BIN
spec/fixtures/mercurial-repo/.hg/store/00changelog.i
vendored
BIN
spec/fixtures/mercurial-repo/.hg/store/00changelog.i
vendored
Binary file not shown.
BIN
spec/fixtures/mercurial-repo/.hg/store/00manifest.i
vendored
BIN
spec/fixtures/mercurial-repo/.hg/store/00manifest.i
vendored
Binary file not shown.
BIN
spec/fixtures/mercurial-repo/.hg/store/data/_mercurial_source.podspec.i
vendored
Normal file
BIN
spec/fixtures/mercurial-repo/.hg/store/data/_mercurial_source.podspec.i
vendored
Normal file
Binary file not shown.
@@ -1 +1,2 @@
|
||||
data/MercurialSource.podspec.i
|
||||
data/README.i
|
||||
|
||||
1
spec/fixtures/mercurial-repo/.hg/store/phaseroots
vendored
Normal file
1
spec/fixtures/mercurial-repo/.hg/store/phaseroots
vendored
Normal file
@@ -0,0 +1 @@
|
||||
1 3d2759856083e6dbb5b5d0b702aa625b5b21a10a
|
||||
BIN
spec/fixtures/mercurial-repo/.hg/store/undo
vendored
BIN
spec/fixtures/mercurial-repo/.hg/store/undo
vendored
Binary file not shown.
1
spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots
vendored
Normal file
1
spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots
vendored
Normal file
@@ -0,0 +1 @@
|
||||
1 3d2759856083e6dbb5b5d0b702aa625b5b21a10a
|
||||
2
spec/fixtures/mercurial-repo/.hg/undo.desc
vendored
2
spec/fixtures/mercurial-repo/.hg/undo.desc
vendored
@@ -1,2 +1,2 @@
|
||||
1
|
||||
3
|
||||
commit
|
||||
|
||||
BIN
spec/fixtures/mercurial-repo/.hg/undo.dirstate
vendored
BIN
spec/fixtures/mercurial-repo/.hg/undo.dirstate
vendored
Binary file not shown.
10
spec/fixtures/mercurial-repo/MercurialSource.podspec
vendored
Normal file
10
spec/fixtures/mercurial-repo/MercurialSource.podspec
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "MercurialSource"
|
||||
s.version = "0.0.1"
|
||||
s.summary = "A short description of MercurialSource."
|
||||
s.homepage = "http://EXAMPLE/MercurialSource"
|
||||
s.license = 'MIT (example)'
|
||||
s.author = { "Dan Cutting" => "dcutting@gmail.com" }
|
||||
s.source = { :git => "http://EXAMPLE/MercurialSource.git", :tag => "0.0.1" }
|
||||
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
|
||||
end
|
||||
@@ -106,6 +106,19 @@ module Pod
|
||||
path.should.exist?
|
||||
end
|
||||
|
||||
it "marks a LocalPod as downloaded if it's from MercurialSource" do
|
||||
dependency = Dependency.new("MercurialSource", :hg => fixture('mercurial-repo'))
|
||||
dependency.external_source.copy_external_source_into_sandbox(@sandbox, Platform.ios)
|
||||
@sandbox.installed_pod_named('MercurialSource', Platform.ios).downloaded.should.be.true
|
||||
end
|
||||
|
||||
it "creates a copy of the podspec (MercurialSource)" do
|
||||
dependency = Dependency.new("MercurialSource", :hg => fixture('mercurial-repo'))
|
||||
dependency.external_source.copy_external_source_into_sandbox(@sandbox, Platform.ios)
|
||||
path = @sandbox.root + 'Local Podspecs/MercurialSource.podspec'
|
||||
path.should.exist?
|
||||
end
|
||||
|
||||
it "marks a LocalPod as downloaded if it's from SvnSource" do
|
||||
dependency = Dependency.new("SvnSource", :svn => "file://#{fixture('subversion-repo/trunk')}")
|
||||
dependency.external_source.copy_external_source_into_sandbox(@sandbox, Platform.ios)
|
||||
|
||||
Reference in New Issue
Block a user