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
cfbdef54
Commit
cfbdef54
authored
May 09, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored Pod::Downloader::Git::GitHub.
parent
ac233ae8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
0 deletions
+93
-0
downloader.rb
lib/cocoapods/downloader.rb
+5
-0
git.rb
lib/cocoapods/downloader/git.rb
+49
-0
downloader_spec.rb
spec/unit/downloader_spec.rb
+39
-0
No files found.
lib/cocoapods/downloader.rb
View file @
cfbdef54
...
@@ -3,6 +3,7 @@ require 'uri'
...
@@ -3,6 +3,7 @@ require 'uri'
module
Pod
module
Pod
class
Downloader
class
Downloader
autoload
:Git
,
'cocoapods/downloader/git'
autoload
:Git
,
'cocoapods/downloader/git'
autoload
:GitHub
,
'cocoapods/downloader/git'
autoload
:Mercurial
,
'cocoapods/downloader/mercurial'
autoload
:Mercurial
,
'cocoapods/downloader/mercurial'
autoload
:Subversion
,
'cocoapods/downloader/subversion'
autoload
:Subversion
,
'cocoapods/downloader/subversion'
autoload
:Http
,
'cocoapods/downloader/http'
autoload
:Http
,
'cocoapods/downloader/http'
...
@@ -31,7 +32,11 @@ module Pod
...
@@ -31,7 +32,11 @@ module Pod
def
self
.
for_target
(
target_path
,
options
)
def
self
.
for_target
(
target_path
,
options
)
options
=
options
.
dup
options
=
options
.
dup
if
url
=
options
.
delete
(
:git
)
if
url
=
options
.
delete
(
:git
)
if
url
.
to_s
=~
/github.com/
GitHub
.
new
(
target_path
,
url
,
options
)
else
Git
.
new
(
target_path
,
url
,
options
)
Git
.
new
(
target_path
,
url
,
options
)
end
elsif
url
=
options
.
delete
(
:hg
)
elsif
url
=
options
.
delete
(
:hg
)
Mercurial
.
new
(
target_path
,
url
,
options
)
Mercurial
.
new
(
target_path
,
url
,
options
)
elsif
url
=
options
.
delete
(
:svn
)
elsif
url
=
options
.
delete
(
:svn
)
...
...
lib/cocoapods/downloader/git.rb
View file @
cfbdef54
...
@@ -103,5 +103,54 @@ module Pod
...
@@ -103,5 +103,54 @@ module Pod
(
target_path
+
'.git'
).
rmtree
(
target_path
+
'.git'
).
rmtree
end
end
end
end
class
GitHub
<
Git
def
download_head
download_only?
?
download_and_extract_tarball
(
'master'
)
:
super
end
def
download_tag
super
unless
download_only?
download_only?
?
download_and_extract_tarball
(
options
[:
tag
])
:
super
end
def
download_commit
super
unless
download_only?
download_only?
?
download_and_extract_tarball
(
options
[:
commit
])
:
super
end
def
clean
if
download_only?
FileUtils
.
rm_f
(
tmp_path
)
else
super
end
end
def
tarball_url_for
(
id
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
"https://github.com/
#{
username
}
/
#{
reponame
}
/tarball/
#{
id
}
"
end
def
tmp_path
target_path
+
"tarball.tar.gz"
end
private
def
download_only?
@options
[
:download_only
]
end
def
download_and_extract_tarball
(
id
)
File
.
open
(
tmp_path
,
"w+"
)
do
|
tmpfile
|
open
tarball_url_for
(
id
)
do
|
archive
|
tmpfile
.
write
Zlib
::
GzipReader
.
new
(
archive
).
read
end
system
"tar xf
#{
tmpfile
.
path
}
-C
#{
target_path
}
--strip-components 1"
end
end
end
end
end
end
end
spec/unit/downloader_spec.rb
View file @
cfbdef54
...
@@ -19,4 +19,43 @@ describe "Pod::Downloader" do
...
@@ -19,4 +19,43 @@ describe "Pod::Downloader" do
downloader
.
url
.
should
==
'http://banana-corp.local/banana-lib.git'
downloader
.
url
.
should
==
'http://banana-corp.local/banana-lib.git'
downloader
.
options
.
should
==
{
:tag
=>
'v1.0'
}
downloader
.
options
.
should
==
{
:tag
=>
'v1.0'
}
end
end
it
'returns a github downloader when the :git URL is on github'
do
pod
=
Pod
::
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Pod
::
Platform
.
ios
)
pod
.
specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/CocoaPods/CocoaPods"
)
downloader
=
Pod
::
Downloader
.
for_pod
(
pod
)
downloader
.
should
.
be
.
instance_of
Pod
::
Downloader
::
GitHub
end
end
describe
Pod
::
Downloader
::
GitHub
do
it
'can convert public HTTP repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"https://github.com/CocoaPods/CocoaPods.git"
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
it
'can convert private HTTP repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"https://lukeredpath@github.com/CocoaPods/CocoaPods.git"
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
it
'can convert private SSH repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"git@github.com:CocoaPods/CocoaPods.git"
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
it
'can convert public git protocol repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"git://github.com/CocoaPods/CocoaPods.git"
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
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