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
bac6f241
Commit
bac6f241
authored
Mar 19, 2018
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Look up references for a path by both given & real paths
parent
236cd833
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
project.rb
lib/cocoapods/project.rb
+10
-10
project_spec.rb
spec/unit/project_spec.rb
+2
-1
No files found.
lib/cocoapods/project.rb
View file @
bac6f241
...
@@ -202,15 +202,14 @@ module Pod
...
@@ -202,15 +202,14 @@ module Pod
# @return [PBXFileReference] The new file reference.
# @return [PBXFileReference] The new file reference.
#
#
def
add_file_reference
(
absolute_path
,
group
,
reflect_file_system_structure
=
false
,
base_path
=
nil
)
def
add_file_reference
(
absolute_path
,
group
,
reflect_file_system_structure
=
false
,
base_path
=
nil
)
file_path_name
=
absolute_path
.
is_a?
(
Pathname
)
?
absolute_path
:
Pathname
.
new
(
absolute_path
)
file_path_name
=
absolute_path
.
is_a?
(
Pathname
)
?
absolute_path
:
Pathname
(
absolute_path
)
group
=
group_for_path_in_group
(
file_path_name
,
group
,
reflect_file_system_structure
,
base_path
)
if
ref
=
reference_for_path
(
file_path_name
)
if
ref
=
reference_for_path
(
file_path_name
.
realpath
)
return
ref
@refs_by_absolute_path
[
absolute_path
.
to_s
]
=
ref
ref
else
ref
=
group
.
new_file
(
file_path_name
.
realpath
)
@refs_by_absolute_path
[
absolute_path
.
to_s
]
=
ref
end
end
group
=
group_for_path_in_group
(
file_path_name
,
group
,
reflect_file_system_structure
,
base_path
)
ref
=
group
.
new_file
(
file_path_name
.
realpath
)
@refs_by_absolute_path
[
file_path_name
.
to_s
]
=
ref
end
end
# Returns the file reference for the given absolute path.
# Returns the file reference for the given absolute path.
...
@@ -222,11 +221,12 @@ module Pod
...
@@ -222,11 +221,12 @@ module Pod
# @return [Nil] If no file reference could be found.
# @return [Nil] If no file reference could be found.
#
#
def
reference_for_path
(
absolute_path
)
def
reference_for_path
(
absolute_path
)
unless
Pathname
.
new
(
absolute_path
).
absolute?
absolute_path
=
absolute_path
.
is_a?
(
Pathname
)
?
absolute_path
:
Pathname
(
absolute_path
)
unless
absolute_path
.
absolute?
raise
ArgumentError
,
"Paths must be absolute
#{
absolute_path
}
"
raise
ArgumentError
,
"Paths must be absolute
#{
absolute_path
}
"
end
end
refs_by_absolute_path
[
absolute_path
.
to_s
]
refs_by_absolute_path
[
absolute_path
.
to_s
]
||=
refs_by_absolute_path
[
absolute_path
.
realpath
.
to_s
]
end
end
# Adds a file reference to the Podfile.
# Adds a file reference to the Podfile.
...
...
spec/unit/project_spec.rb
View file @
bac6f241
...
@@ -364,7 +364,7 @@ module Pod
...
@@ -364,7 +364,7 @@ module Pod
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'file.m'
@file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'file.m'
@group
=
@project
.
group_for_spec
(
'BananaLib'
)
@group
=
@project
.
group_for_spec
(
'BananaLib'
)
Pathname
.
any_instanc
e
.
stubs
(
:realpath
).
returns
(
@file
)
@fil
e
.
stubs
(
:realpath
).
returns
(
@file
)
@project
.
add_file_reference
(
@file
,
@group
)
@project
.
add_file_reference
(
@file
,
@group
)
end
end
...
@@ -375,6 +375,7 @@ module Pod
...
@@ -375,6 +375,7 @@ module Pod
it
'returns nil if no reference for the given path is available'
do
it
'returns nil if no reference for the given path is available'
do
another_file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'another_file.m'
another_file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
'another_file.m'
another_file
.
stubs
(
:realpath
).
returns
(
another_file
)
ref
=
@project
.
reference_for_path
(
another_file
)
ref
=
@project
.
reference_for_path
(
another_file
)
ref
.
should
.
be
.
nil
ref
.
should
.
be
.
nil
end
end
...
...
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