Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
d534af61
Commit
d534af61
authored
Sep 14, 2017
by
Eric Amorde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not force include master spec repo if plugin sources are provided
parent
f3650d11
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
22 deletions
+63
-22
CHANGELOG.md
CHANGELOG.md
+4
-0
installer.rb
lib/cocoapods/installer.rb
+6
-5
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+16
-5
installer_spec.rb
spec/unit/installer_spec.rb
+37
-12
No files found.
CHANGELOG.md
View file @
d534af61
...
@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
##### Enhancements
*
Do not force include the master spec repo if plugins provide sources
[
Eric Amorde
](
https://github.com/amorde
)
[
#7033
](
https://github.com/CocoaPods/CocoaPods/pull/7033
)
*
Add custom shell script integration from Podfile
*
Add custom shell script integration from Podfile
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6820
](
https://github.com/CocoaPods/CocoaPods/pull/6820
)
[
#6820
](
https://github.com/CocoaPods/CocoaPods/pull/6820
)
...
...
lib/cocoapods/installer.rb
View file @
d534af61
...
@@ -140,11 +140,11 @@ module Pod
...
@@ -140,11 +140,11 @@ module Pod
end
end
end
end
# @return [Analyzer] The analyzer used to resolve dependencies
#
def
resolve_dependencies
def
resolve_dependencies
analyzer
=
create_analyzer
plugin_sources
=
run_source_provider_hooks
plugin_sources
=
run_source_provider_hooks
analyzer
.
sources
.
insert
(
0
,
*
plugin_sources
)
analyzer
=
create_analyzer
(
plugin_sources
)
UI
.
section
'Updating local specs repositories'
do
UI
.
section
'Updating local specs repositories'
do
analyzer
.
update_repositories
analyzer
.
update_repositories
...
@@ -155,6 +155,7 @@ module Pod
...
@@ -155,6 +155,7 @@ module Pod
validate_build_configurations
validate_build_configurations
clean_sandbox
clean_sandbox
end
end
analyzer
end
end
def
download_dependencies
def
download_dependencies
...
@@ -243,8 +244,8 @@ module Pod
...
@@ -243,8 +244,8 @@ module Pod
@aggregate_targets
=
analyzer
.
result
.
targets
@aggregate_targets
=
analyzer
.
result
.
targets
end
end
def
create_analyzer
def
create_analyzer
(
plugin_sources
=
nil
)
Analyzer
.
new
(
sandbox
,
podfile
,
lockfile
).
tap
do
|
analyzer
|
Analyzer
.
new
(
sandbox
,
podfile
,
lockfile
,
plugin_sources
).
tap
do
|
analyzer
|
analyzer
.
installation_options
=
installation_options
analyzer
.
installation_options
=
installation_options
analyzer
.
has_dependencies
=
has_dependencies?
analyzer
.
has_dependencies
=
has_dependencies?
end
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
d534af61
...
@@ -32,16 +32,22 @@ module Pod
...
@@ -32,16 +32,22 @@ module Pod
#
#
attr_reader
:lockfile
attr_reader
:lockfile
# @return [Array<Source>] Sources provided by plugins
#
attr_reader
:plugin_sources
# Initialize a new instance
# Initialize a new instance
#
#
# @param [Sandbox] sandbox @see sandbox
# @param [Sandbox] sandbox @see sandbox
# @param [Podfile] podfile @see podfile
# @param [Podfile] podfile @see podfile
# @param [Lockfile] lockfile @see lockfile
# @param [Lockfile] lockfile @see lockfile
# @param [Array<Source>] plugin_sources @see plugin_sources
#
#
def
initialize
(
sandbox
,
podfile
,
lockfile
=
nil
)
def
initialize
(
sandbox
,
podfile
,
lockfile
=
nil
,
plugin_sources
=
nil
)
@sandbox
=
sandbox
@sandbox
=
sandbox
@podfile
=
podfile
@podfile
=
podfile
@lockfile
=
lockfile
@lockfile
=
lockfile
@plugin_sources
=
plugin_sources
@update
=
false
@update
=
false
@allow_pre_downloads
=
true
@allow_pre_downloads
=
true
...
@@ -825,8 +831,8 @@ module Pod
...
@@ -825,8 +831,8 @@ module Pod
# Returns the sources used to query for specifications
# Returns the sources used to query for specifications
#
#
# When no explicit Podfile sources
are defined, this defaults to the
# When no explicit Podfile sources
or plugin sources are defined, this
# master spec repository.
#
defaults to the
master spec repository.
# available sources ({config.sources_manager.all}).
# available sources ({config.sources_manager.all}).
#
#
# @return [Array<Source>] the sources to be used in finding
# @return [Array<Source>] the sources to be used in finding
...
@@ -835,6 +841,7 @@ module Pod
...
@@ -835,6 +841,7 @@ module Pod
def
sources
def
sources
@sources
||=
begin
@sources
||=
begin
sources
=
podfile
.
sources
sources
=
podfile
.
sources
plugin_sources
=
@plugin_sources
||
[]
# Add any sources specified using the :source flag on individual dependencies.
# Add any sources specified using the :source flag on individual dependencies.
dependency_sources
=
podfile
.
dependencies
.
map
(
&
:podspec_repo
).
compact
dependency_sources
=
podfile
.
dependencies
.
map
(
&
:podspec_repo
).
compact
...
@@ -842,15 +849,19 @@ module Pod
...
@@ -842,15 +849,19 @@ module Pod
if
all_dependencies_have_sources
if
all_dependencies_have_sources
sources
=
dependency_sources
sources
=
dependency_sources
elsif
has_dependencies?
&&
sources
.
empty?
elsif
has_dependencies?
&&
sources
.
empty?
&&
plugin_sources
.
empty?
sources
=
[
'https://github.com/CocoaPods/Specs.git'
]
sources
=
[
'https://github.com/CocoaPods/Specs.git'
]
else
else
sources
+=
dependency_sources
sources
+=
dependency_sources
end
end
sources
.
uniq
.
map
do
|
source_url
|
result
=
sources
.
uniq
.
map
do
|
source_url
|
config
.
sources_manager
.
find_or_create_source_with_url
(
source_url
)
config
.
sources_manager
.
find_or_create_source_with_url
(
source_url
)
end
end
unless
plugin_sources
.
empty?
result
.
insert
(
0
,
*
plugin_sources
)
end
result
end
end
end
end
...
...
spec/unit/installer_spec.rb
View file @
d534af61
...
@@ -103,48 +103,73 @@ module Pod
...
@@ -103,48 +103,73 @@ module Pod
@installer
.
install!
@installer
.
install!
end
end
describe
'handling spec sources'
do
before
do
@hooks_manager
=
Pod
::
HooksManager
@hooks_manager
.
instance_variable_set
(
:@registrations
,
nil
)
end
it
'runs source provider hooks before analyzing'
do
it
'runs source provider hooks before analyzing'
do
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:clean_sandbox
)
@installer
.
stubs
(
:clean_sandbox
)
def
@installer
.
run_source_provider_hooks
@installer
.
stubs
(
:analyze
)
@installer
.
stubs
(
:run_source_provider_hooks
).
with
do
@hook_called
=
true
@hook_called
=
true
end
end
def
@installer
.
analyze
(
*
)
@hook_called
.
should
.
be
.
true
end
@installer
.
install!
@installer
.
install!
@hook_called
.
should
.
be
.
true
end
end
it
'includes sources from source provider plugins'
do
it
'includes sources from source provider plugins'
do
plugin_name
=
'test-plugin'
plugin_name
=
'test-plugin'
Pod
::
HooksM
anager
.
register
(
plugin_name
,
:source_provider
)
do
|
context
,
options
|
@hooks_m
anager
.
register
(
plugin_name
,
:source_provider
)
do
|
context
,
options
|
source_url
=
options
[
'sources'
].
first
source_url
=
options
[
'sources'
].
first
return
unless
source_url
return
unless
source_url
source
=
Pod
::
Source
.
new
(
source_url
)
source
=
Pod
::
Source
.
new
(
source_url
)
context
.
add_source
(
source
)
context
.
add_source
(
source
)
end
end
test_source_name
=
'https://github.com/artsy/
Specs.git'
test_source_name
=
'https://github.com/artsy/Custom
Specs.git'
plugins_hash
=
Installer
::
DEFAULT_PLUGINS
.
merge
(
plugin_name
=>
{
'sources'
=>
[
test_source_name
]
})
plugins_hash
=
Installer
::
DEFAULT_PLUGINS
.
merge
(
plugin_name
=>
{
'sources'
=>
[
test_source_name
]
})
@installer
.
podfile
.
stubs
(
:plugins
).
returns
(
plugins_hash
)
@installer
.
podfile
.
stubs
(
:plugins
).
returns
(
plugins_hash
)
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:clean_sandbox
)
@installer
.
stubs
(
:clean_sandbox
)
@installer
.
stubs
(
:ensure_plugins_are_installed!
)
@installer
.
stubs
(
:analyze
)
@installer
.
stubs
(
:analyze
)
Installer
::
Analyzer
.
any_instance
.
stubs
(
:update_repositories
)
analyzer
=
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@installer
.
podfile
,
@installer
.
lockfile
)
analyzer
=
@installer
.
resolve_dependencies
analyzer
.
stubs
(
:analyze
)
@installer
.
stubs
(
:create_analyzer
).
returns
(
analyzer
)
@installer
.
install!
source
=
Pod
::
Source
.
new
(
test_source_name
)
source
=
Pod
::
Source
.
new
(
test_source_name
)
names
=
analyzer
.
sources
.
map
(
&
:name
)
names
=
analyzer
.
sources
.
map
(
&
:name
)
names
.
should
.
include
(
source
.
name
)
names
.
should
.
include
(
source
.
name
)
end
end
it
'does not automatically add master spec repo if plugin sources exist'
do
plugin_name
=
'test-plugin'
@hooks_manager
.
register
(
plugin_name
,
:source_provider
)
do
|
context
,
options
|
source_url
=
options
[
'sources'
].
first
return
unless
source_url
source
=
Pod
::
Source
.
new
(
source_url
)
context
.
add_source
(
source
)
end
test_source_name
=
'https://github.com/artsy/CustomSpecs.git'
plugins_hash
=
Installer
::
DEFAULT_PLUGINS
.
merge
(
plugin_name
=>
{
'sources'
=>
[
test_source_name
]
})
@installer
.
podfile
.
stubs
(
:plugins
).
returns
(
plugins_hash
)
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:clean_sandbox
)
@installer
.
stubs
(
:analyze
)
Installer
::
Analyzer
.
any_instance
.
stubs
(
:update_repositories
)
analyzer
=
@installer
.
resolve_dependencies
names
=
analyzer
.
sources
.
map
(
&
:name
)
names
.
should
==
[
Pod
::
Source
.
new
(
'https://github.com/artsy/CustomSpecs.git'
).
name
]
end
end
it
'integrates the user targets if the corresponding config is set'
do
it
'integrates the user targets if the corresponding config is set'
do
@installer
.
installation_options
.
integrate_targets
=
true
@installer
.
installation_options
.
integrate_targets
=
true
@installer
.
expects
(
:integrate_user_project
)
@installer
.
expects
(
:integrate_user_project
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment