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
ecd9229e
Commit
ecd9229e
authored
Oct 29, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Analyzer] Improve handling of different types of duplicate dependencies
parent
6ea048ac
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
1 deletion
+106
-1
CHANGELOG.md
CHANGELOG.md
+12
-0
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+13
-1
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+81
-0
No files found.
CHANGELOG.md
View file @
ecd9229e
...
...
@@ -60,6 +60,18 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Eloy Durán
](
https://github.com/alloy
)
[
#2722
](
https://github.com/CocoaPods/CocoaPods/pull/2722
)
*
Analysis is now halted and the user informed when there are multiple different
external sources for dependencies with the same root name.
The user is also now warned when there are duplicate dependencies in the
Podfile.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2738
](
https://github.com/CocoaPods/CocoaPods/issues/2738
)
*
Multiple subspecs that point to the same external dependency will now only
cause that external source to be fetched once.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2743
](
https://github.com/CocoaPods/CocoaPods/issues/2743
)
##### Bug Fixes
*
Do not try to clone spec-repos in
`/`
.
...
...
lib/cocoapods/installer/analyzer.rb
View file @
ecd9229e
...
...
@@ -268,6 +268,11 @@ module Pod
deps_to_fetch_if_needed
=
[]
deps_with_external_source
=
podfile
.
dependencies
.
select
(
&
:external_source
)
deps_with_different_sources
=
podfile
.
dependencies
.
group_by
(
&
:root_name
).
select
{
|
_root_name
,
dependencies
|
dependencies
.
map
(
&
:external_source
).
uniq
.
count
>
1
}
deps_with_different_sources
.
each
do
|
root_name
,
dependencies
|
raise
Informative
,
"There are multiple dependencies with different sources for `
#{
root_name
}
` in
#{
UI
.
path
podfile
.
defined_in_file
}
:
\n\n
-
#{
dependencies
.
map
(
&
:to_s
).
join
(
"
\n
- "
)
}
"
end
if
update_mode
==
:all
deps_to_fetch
=
deps_with_external_source
else
...
...
@@ -282,7 +287,7 @@ module Pod
unless
deps_to_fetch
.
empty?
UI
.
section
'Fetching external sources'
do
deps_to_fetch
.
uniq
.
sort
.
each
do
|
dependency
|
deps_to_fetch
.
uniq
(
&
:root_name
)
.
sort
.
each
do
|
dependency
|
source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile
.
defined_in_file
)
source
.
fetch
(
sandbox
)
end
...
...
@@ -310,6 +315,13 @@ module Pod
# grouped by target.
#
def
resolve_dependencies
duplicate_dependencies
=
podfile
.
dependencies
.
group_by
(
&
:name
).
select
{
|
_name
,
dependencies
|
dependencies
.
count
>
1
}
duplicate_dependencies
.
each
do
|
name
,
dependencies
|
UI
.
warn
"There are duplicate dependencies on `
#{
name
}
` in
#{
UI
.
path
podfile
.
defined_in_file
}
:
\n\n
"
\
"-
#{
dependencies
.
map
(
&
:to_s
).
join
(
"
\n
- "
)
}
"
end
specs_by_target
=
nil
UI
.
section
"Resolving dependencies of
#{
UI
.
path
podfile
.
defined_in_file
}
"
do
resolver
=
Resolver
.
new
(
sandbox
,
podfile
,
locked_dependencies
,
sources
)
...
...
spec/unit/installer/analyzer_spec.rb
View file @
ecd9229e
...
...
@@ -173,6 +173,69 @@ module Pod
@analyzer
.
send
(
:fetch_external_sources
)
end
it
'does not download the same source multiple times for different subspecs'
do
podfile_state
=
Installer
::
Analyzer
::
SpecsState
.
new
podfile_state
.
added
<<
'ARAnalytics/Mixpanel'
<<
'ARAnalytics/HockeyApp'
@analyzer
.
stubs
(
:result
).
returns
(
stub
(
:podfile_state
=>
podfile_state
))
@podfile
.
stubs
(
:dependencies
).
returns
([
Dependency
.
new
(
'ARAnalytics/Mixpanel'
,
:git
=>
'https://github.com/orta/ARAnalytics'
,
:commit
=>
'6f1a1c314894437e7e5c09572c276e644dbfb64b'
),
Dependency
.
new
(
'ARAnalytics/HockeyApp'
,
:git
=>
'https://github.com/orta/ARAnalytics'
,
:commit
=>
'6f1a1c314894437e7e5c09572c276e644dbfb64b'
),
])
ExternalSources
::
DownloaderSource
.
any_instance
.
expects
(
:fetch
).
once
@analyzer
.
send
(
:fetch_external_sources
)
end
it
'raises when dependencies with the same name have different '
\
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/SEGModules.git'
pod
'SEGModules'
,
:git
=>
'https://github.com/segiddins/Modules.git'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `SEGModules`/
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/SEGModules.git`
\)
}
e
.
message
.
should
.
match
%r{SEGModules
\(
from `https://github.com/segiddins/Modules.git`
\)
}
end
it
'raises when dependencies with the same root name have different '
\
'external sources'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit/Core'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
:git
=>
'https://github.com/segiddins/RestKit.git'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `RestKit`/
e
.
message
.
should
.
match
%r{RestKit/Core
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/segiddins/RestKit.git`
\)
}
end
it
'raises when dependencies with the same name have different '
\
'external sources with one being nil'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
pod
'RestKit'
,
:git
=>
'https://github.com/RestKit/RestKit.git'
pod
'RestKit'
,
'~> 0.23.0'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
e
=
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
e
.
message
.
should
.
match
/different sources for `RestKit`/
e
.
message
.
should
.
match
%r{RestKit
\(
from `https://github.com/RestKit/RestKit.git`
\)
}
e
.
message
.
should
.
match
%r{RestKit
\(
~> 0.23.0
\)
}
end
xit
'it fetches the specification from either the sandbox or from the remote be default'
do
dependency
=
Dependency
.
new
(
'Name'
,
:git
=>
'www.example.com'
)
ExternalSources
::
DownloaderSource
.
any_instance
.
expects
(
:specification_from_external
).
returns
(
Specification
.
new
).
once
...
...
@@ -224,6 +287,24 @@ module Pod
#--------------------------------------#
it
'warns when a dependency is duplicated'
do
podfile
=
Podfile
.
new
do
source
'https://github.com/CocoaPods/Specs.git'
xcodeproj
'SampleProject/SampleProject'
platform
:ios
,
'8.0'
pod
'RestKit'
,
'~> 0.23.0'
pod
'RestKit'
,
'<= 0.23.2'
end
analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
podfile
,
nil
)
analyzer
.
analyze
UI
.
warnings
.
should
.
match
/duplicate dependencies on `RestKit`/
UI
.
warnings
.
should
.
match
%r{RestKit
\(
~> 0.23.0
\)
}
UI
.
warnings
.
should
.
match
%r{RestKit
\(
<= 0.23.2
\)
}
end
#--------------------------------------#
it
'computes the state of the Sandbox respect to the resolved dependencies'
do
@analyzer
.
stubs
(
:lockfile
).
returns
(
nil
)
state
=
@analyzer
.
analyze
.
sandbox_state
...
...
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