mirror of
https://github.com/zhigang1992/CocoaPods.git
synced 2026-01-12 17:12:54 +08:00
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
|
||||
Podspec for testing direct Mercurial support within Podfiles.
|
||||
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.
0
spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots
vendored
Normal file
0
spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots
vendored
Normal file
2
spec/fixtures/mercurial-repo/.hg/undo.desc
vendored
2
spec/fixtures/mercurial-repo/.hg/undo.desc
vendored
@@ -1,2 +1,2 @@
|
||||
1
|
||||
2
|
||||
commit
|
||||
|
||||
BIN
spec/fixtures/mercurial-repo/.hg/undo.dirstate
vendored
BIN
spec/fixtures/mercurial-repo/.hg/undo.dirstate
vendored
Binary file not shown.
130
spec/fixtures/mercurial-repo/MercurialSource.podspec
vendored
Normal file
130
spec/fixtures/mercurial-repo/MercurialSource.podspec
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
#
|
||||
# Be sure to run `pod spec lint MercurialSource.podspec' to ensure this is a
|
||||
# valid spec.
|
||||
#
|
||||
# Remove all comments before submitting the spec. Optional attributes are commented.
|
||||
#
|
||||
# For details see: https://github.com/CocoaPods/CocoaPods/wiki/The-podspec-format
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "MercurialSource"
|
||||
s.version = "0.0.1"
|
||||
s.summary = "A short description of MercurialSource."
|
||||
# s.description = <<-DESC
|
||||
# An optional longer description of MercurialSource
|
||||
#
|
||||
# * Markdown format.
|
||||
# * Don't worry about the indent, we strip it!
|
||||
# DESC
|
||||
s.homepage = "http://EXAMPLE/MercurialSource"
|
||||
|
||||
# Specify the license type. CocoaPods detects automatically the license file if it is named
|
||||
# `LICEN{C,S}E*.*', however if the name is different, specify it.
|
||||
s.license = 'MIT (example)'
|
||||
# s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' }
|
||||
#
|
||||
# Only if no dedicated file is available include the full text of the license.
|
||||
#
|
||||
# s.license = {
|
||||
# :type => 'MIT (example)',
|
||||
# :text => <<-LICENSE
|
||||
# Copyright (C) <year> <copyright holders>
|
||||
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# ...
|
||||
# LICENSE
|
||||
# }
|
||||
|
||||
# Specify the authors of the library, with email addresses. You can often find
|
||||
# the email addresses of the authors by using the SCM log. E.g. $ git log
|
||||
#
|
||||
s.author = { "Dan Cutting" => "dcutting@gmail.com" }
|
||||
# s.authors = { "Dan Cutting" => "dcutting@gmail.com", "other author" => "and email address" }
|
||||
#
|
||||
# If absolutely no email addresses are available, then you can use this form instead.
|
||||
#
|
||||
# s.author = 'Dan Cutting', 'other author'
|
||||
|
||||
# Specify the location from where the source should be retrieved.
|
||||
#
|
||||
s.source = { :git => "http://EXAMPLE/MercurialSource.git", :tag => "0.0.1" }
|
||||
# s.source = { :svn => 'http://EXAMPLE/MercurialSource/tags/1.0.0' }
|
||||
# s.source = { :hg => 'http://EXAMPLE/MercurialSource', :revision => '1.0.0' }
|
||||
|
||||
# If this Pod runs only on iOS or OS X, then specify the platform and
|
||||
# the deployment target.
|
||||
#
|
||||
# s.platform = :ios, '5.0'
|
||||
# s.platform = :ios
|
||||
|
||||
# ――― MULTI-PLATFORM VALUES ――――――――――――――――――――――――――――――――――――――――――――――――― #
|
||||
|
||||
# If this Pod runs on both platforms, then specify the deployment
|
||||
# targets.
|
||||
#
|
||||
# s.ios.deployment_target = '5.0'
|
||||
# s.osx.deployment_target = '10.7'
|
||||
|
||||
# A list of file patterns which select the source files that should be
|
||||
# added to the Pods project. If the pattern is a directory then the
|
||||
# path will automatically have '*.{h,m,mm,c,cpp}' appended.
|
||||
#
|
||||
# Alternatively, you can use the FileList class for even more control
|
||||
# over the selected files.
|
||||
# (See http://rake.rubyforge.org/classes/Rake/FileList.html.)
|
||||
#
|
||||
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
|
||||
|
||||
# A list of file patterns which select the header files that should be
|
||||
# made available to the application. If the pattern is a directory then the
|
||||
# path will automatically have '*.h' appended.
|
||||
#
|
||||
# Also allows the use of the FileList class like `source_files' does.
|
||||
#
|
||||
# If you do not explicitly set the list of public header files,
|
||||
# all headers of source_files will be made public.
|
||||
#
|
||||
# s.public_header_files = 'Classes/**/*.h'
|
||||
|
||||
# A list of resources included with the Pod. These are copied into the
|
||||
# target bundle with a build phase script.
|
||||
#
|
||||
# Also allows the use of the FileList class like `source_files' does.
|
||||
#
|
||||
# s.resource = "icon.png"
|
||||
# s.resources = "Resources/*.png"
|
||||
|
||||
# A list of paths to preserve after installing the Pod.
|
||||
# CocoaPods cleans by default any file that is not used.
|
||||
# Please don't include documentation, example, and test files.
|
||||
# Also allows the use of the FileList class like `source_files' does.
|
||||
#
|
||||
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
|
||||
|
||||
# Specify a list of frameworks that the application needs to link
|
||||
# against for this Pod to work.
|
||||
#
|
||||
# s.framework = 'SomeFramework'
|
||||
# s.frameworks = 'SomeFramework', 'AnotherFramework'
|
||||
|
||||
# Specify a list of libraries that the application needs to link
|
||||
# against for this Pod to work.
|
||||
#
|
||||
# s.library = 'iconv'
|
||||
# s.libraries = 'iconv', 'xml2'
|
||||
|
||||
# If this Pod uses ARC, specify it like so.
|
||||
#
|
||||
# s.requires_arc = true
|
||||
|
||||
# If you need to specify any other build settings, add them to the
|
||||
# xcconfig hash.
|
||||
#
|
||||
# s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
|
||||
|
||||
# Finally, specify any Pods that this Pod depends on.
|
||||
#
|
||||
# s.dependency 'JSONKit', '~> 1.4'
|
||||
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