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
39b687ee
Commit
39b687ee
authored
Nov 18, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Mercurial downloader. Closes #82.
parent
44a60c51
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
72 deletions
+117
-72
.gitignore
.gitignore
+2
-0
downloader.rb
lib/cocoapods/downloader.rb
+3
-70
git.rb
lib/cocoapods/downloader/git.rb
+46
-0
mercurial.rb
lib/cocoapods/downloader/mercurial.rb
+30
-0
downloader_spec.rb
spec/functional/downloader_spec.rb
+36
-2
No files found.
.gitignore
View file @
39b687ee
...
...
@@ -13,3 +13,4 @@ examples/**/Pods
spec/fixtures/banana-lib
pod
/concatenated.*
spec/fixtures/mercurial-repo/.hg/cache
\ No newline at end of file
lib/cocoapods/downloader.rb
View file @
39b687ee
module
Pod
class
Downloader
autoload
:Git
,
'cocoapods/downloader/git'
autoload
:Mercurial
,
'cocoapods/downloader/mercurial'
extend
Executable
def
self
.
for_source
(
pod_root
,
source
)
...
...
@@ -24,75 +27,5 @@ module Pod
path
.
rmtree
end
if
clean_paths
end
class
Git
<
Downloader
executable
:git
def
download
@pod_root
.
dirname
.
mkpath
if
@options
[
:tag
]
download_tag
elsif
@options
[
:commit
]
download_commit
else
download_head
end
end
def
download_head
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
end
def
download_tag
@pod_root
.
mkpath
Dir
.
chdir
(
@pod_root
)
do
git
"init"
git
"remote add origin '
#{
@url
}
'"
git
"fetch origin tags/
#{
@options
[
:tag
]
}
"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit"
end
end
def
download_commit
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
Dir
.
chdir
(
@pod_root
)
do
git
"checkout -b activated-pod-commit
#{
@options
[
:commit
]
}
"
end
end
def
clean
(
clean_paths
=
[])
super
(
@pod_root
+
'.git'
).
rmtree
end
end
class
Mercurial
<
Downloader
extend
Executable
executable
:hg
def
download
@pod_root
.
dirname
.
mkpath
if
@options
[
:revision
]
download_revision
else
download_head
end
end
def
download_head
hg
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
end
def
download_revision
hg
"clone '
#{
@url
}
' --rev '
#{
@options
[
:revision
]
}
' '
#{
@pod_root
}
'"
end
def
clean
(
clean_paths
=
[])
super
#(@pod_root + '.git').rmtree
puts
"TODO clean mercurial!"
end
end
end
end
lib/cocoapods/downloader/git.rb
0 → 100644
View file @
39b687ee
module
Pod
class
Downloader
class
Git
<
Downloader
executable
:git
def
download
@pod_root
.
dirname
.
mkpath
if
@options
[
:tag
]
download_tag
elsif
@options
[
:commit
]
download_commit
else
download_head
end
end
def
download_head
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
end
def
download_tag
@pod_root
.
mkpath
Dir
.
chdir
(
@pod_root
)
do
git
"init"
git
"remote add origin '
#{
@url
}
'"
git
"fetch origin tags/
#{
@options
[
:tag
]
}
"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit"
end
end
def
download_commit
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
Dir
.
chdir
(
@pod_root
)
do
git
"checkout -b activated-pod-commit
#{
@options
[
:commit
]
}
"
end
end
def
clean
(
clean_paths
=
[])
super
(
@pod_root
+
'.git'
).
rmtree
end
end
end
end
lib/cocoapods/downloader/mercurial.rb
0 → 100644
View file @
39b687ee
module
Pod
class
Downloader
class
Mercurial
<
Downloader
executable
:hg
def
download
@pod_root
.
dirname
.
mkpath
if
@options
[
:revision
]
download_revision
else
download_head
end
end
def
download_head
hg
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
end
def
download_revision
hg
"clone '
#{
@url
}
' --rev '
#{
@options
[
:revision
]
}
' '
#{
@pod_root
}
'"
end
def
clean
(
clean_paths
=
[])
super
(
@pod_root
+
'.hg'
).
rmtree
end
end
end
end
spec/functional/downloader_spec.rb
View file @
39b687ee
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
"Pod::Downloader"
do
extend
SpecHelper
::
TemporaryDirectory
before
do
@dir
=
temporary_directory
+
'banana-lib'
end
describe
"for Git"
do
extend
SpecHelper
::
TemporaryDirectory
it
"check's out a specific commit"
do
downloader
=
Pod
::
Downloader
.
for_source
(
@dir
,
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'02467b074d4dc9f6a75b8cd3ab80d9bf37887b01'
...
...
@@ -40,5 +41,38 @@ describe "Pod::Downloader" do
downloader
.
clean
([
@dir
+
'README'
])
(
@dir
+
'README'
).
should
.
not
.
exist
end
end
describe
"for Mercurial"
do
extend
SpecHelper
::
TemporaryDirectory
it
"check's out a specific revision"
do
downloader
=
Pod
::
Downloader
.
for_source
(
@dir
,
:hg
=>
fixture
(
'mercurial-repo'
),
:revision
=>
'46198bb3af96'
)
downloader
.
download
(
@dir
+
'README'
).
read
.
strip
.
should
==
'first commit'
end
it
"removes the .hg directory"
do
downloader
=
Pod
::
Downloader
.
for_source
(
@dir
,
:hg
=>
fixture
(
'mercurial-repo'
),
:revision
=>
'46198bb3af96'
)
downloader
.
download
downloader
.
clean
(
@dir
+
'.hg'
).
should
.
not
.
exist
end
it
"removes the clean_paths files and directories"
do
downloader
=
Pod
::
Downloader
.
for_source
(
@dir
,
:hg
=>
fixture
(
'mercurial-repo'
),
:revision
=>
'46198bb3af96'
)
downloader
.
download
downloader
.
clean
([
@dir
+
'README'
])
(
@dir
+
'README'
).
should
.
not
.
exist
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