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
5b9704f6
Commit
5b9704f6
authored
Sep 30, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SourcesManager] More robust generation of source names from URLs
parent
d6e438d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
6 deletions
+37
-6
CHANGELOG.md
CHANGELOG.md
+4
-0
sources_manager.rb
lib/cocoapods/sources_manager.rb
+15
-6
sources_manager_spec.rb
spec/unit/sources_manager_spec.rb
+18
-0
No files found.
CHANGELOG.md
View file @
5b9704f6
...
...
@@ -11,6 +11,10 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Boris Bügling
](
https://github.com/neonichu
)
[
#2542
](
https://github.com/CocoaPods/CocoaPods/issues/2542
)
*
More robust generation of source names from URLs.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2534
](
https://github.com/CocoaPods/CocoaPods/issues/2534
)
## 0.34.1
...
...
lib/cocoapods/sources_manager.rb
View file @
5b9704f6
...
...
@@ -405,18 +405,27 @@ module Pod
# @return [String] A suitable repository name for `url`.
#
def
name_for_url
(
url
)
case
url
.
downcase
base_from_host_and_path
=
lambda
do
|
host
,
path
|
base
=
host
.
split
(
'.'
)[
-
2
]
||
host
base
+=
'-'
+
path
.
gsub
(
/.git$/
,
''
).
gsub
(
/^\//
,
''
).
split
(
'/'
).
join
(
'-'
)
end
case
url
.
to_s
.
downcase
when
%r{github.com(:|/)cocoapods/specs}
base
=
'master'
when
%r{github.com(:|/)(.+)/(.+)}
base
=
Regexp
.
last_match
[
2
]
else
raise
Informative
,
"`
#{
url
}
` is not a valid URL."
unless
url
=~
URI
.
regexp
when
URI
.
regexp
url
=
URI
(
url
.
downcase
)
base
=
url
.
host
.
split
(
'.'
)[
-
2
]
+
url
.
path
.
gsub
(
/.git$/
,
''
).
split
(
'/'
).
join
(
'-'
)
base
=
base_from_host_and_path
[
url
.
host
,
url
.
path
]
when
%r{^
\S
+@(
\S
+)[:/](.+)$}
host
,
path
=
Regexp
.
last_match
.
captures
base
=
base_from_host_and_path
[
host
,
path
]
else
url
.
to_s
.
downcase
end
name
=
base
infinity
=
1.0
/
0
(
1
..
infinity
).
each
do
|
i
|
...
...
spec/unit/sources_manager_spec.rb
View file @
5b9704f6
...
...
@@ -127,6 +127,24 @@ module Pod
should
==
'sourceforge-artsy-specs'
end
it
'supports scp-style URLs'
do
url
=
'git@git-host.com/specs.git'
SourcesManager
.
send
(
:name_for_url
,
url
).
should
==
'git-host-specs'
end
it
'supports ssh URLs with an aliased hostname'
do
url
=
'ssh://user@companyalias/pod-specs'
SourcesManager
.
send
(
:name_for_url
,
url
).
should
==
'companyalias-pod-specs'
end
it
'supports ssh URLs with no user component'
do
url
=
'ssh://company.com/pods/specs.git'
SourcesManager
.
send
(
:name_for_url
,
url
).
should
==
'company-pods-specs'
end
it
'appends a number to the name if the base name dir exists'
do
url
=
'https://github.com/segiddins/banana.git'
Pathname
.
any_instance
.
stubs
(
:exist?
).
...
...
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