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
c9dd6934
Commit
c9dd6934
authored
Aug 10, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Downloader] raise when importan commands fail.
parent
139e6e48
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
29 deletions
+73
-29
git.rb
lib/cocoapods/downloader/git.rb
+23
-17
http.rb
lib/cocoapods/downloader/http.rb
+4
-4
mercurial.rb
lib/cocoapods/downloader/mercurial.rb
+2
-2
subversion.rb
lib/cocoapods/downloader/subversion.rb
+2
-2
executable.rb
lib/cocoapods/executable.rb
+16
-3
git_spec.rb
spec/functional/downloader/git_spec.rb
+2
-1
downloader_spec.rb
spec/functional/downloader_spec.rb
+24
-0
No files found.
lib/cocoapods/downloader/git.rb
View file @
c9dd6934
...
...
@@ -25,7 +25,7 @@ module Pod
download_head
end
Dir
.
chdir
(
target_path
)
{
git
"submodule update --init"
}
if
options
[
:submodules
]
Dir
.
chdir
(
target_path
)
{
git
!
"submodule update --init"
}
if
options
[
:submodules
]
prune_cache
end
...
...
@@ -33,7 +33,7 @@ module Pod
puts
"-> Creating cache git repo (
#{
cache_path
}
)"
if
config
.
verbose?
cache_path
.
rmtree
if
cache_path
.
exist?
cache_path
.
mkpath
git
%Q|clone "
#{
url
}
" "
#{
cache_path
}
"|
clone
(
url
,
cache_path
)
end
def
prune_cache
...
...
@@ -76,9 +76,9 @@ module Pod
def
update_cache
puts
"-> Updating cache git repo (
#{
cache_path
}
)"
if
config
.
verbose?
Dir
.
chdir
(
cache_path
)
do
git
"reset --hard HEAD"
git
"clean -d -x -f"
git
"pull"
git
!
"reset --hard HEAD"
git
!
"clean -d -x -f"
git
!
"pull"
end
end
...
...
@@ -106,38 +106,44 @@ module Pod
else
create_cache
end
git
%Q|clone "
#{
clone_url
}
" "
#{
target_path
}
"|
clone
(
clone_url
,
target_path
)
Dir
.
chdir
(
target_path
)
{
git!
"submodule update --init"
}
if
options
[
:submodules
]
end
def
download_tag
ensure_ref_exists
(
options
[
:tag
])
Dir
.
chdir
(
target_path
)
do
git
"init"
git
"remote add origin '
#{
clone_url
}
'"
git
"fetch origin tags/
#{
options
[
:tag
]
}
"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit"
git
!
"init"
git
!
"remote add origin '
#{
clone_url
}
'"
git
!
"fetch origin tags/
#{
options
[
:tag
]
}
"
git
!
"reset --hard FETCH_HEAD"
git
!
"checkout -b activated-pod-commit"
end
end
def
download_commit
ensure_ref_exists
(
options
[
:commit
])
git
%Q|clone "
#{
clone_url
}
" "
#{
target_path
}
"|
clone
(
clone_url
,
target_path
)
Dir
.
chdir
(
target_path
)
do
git
"checkout -b activated-pod-commit
#{
options
[
:commit
]
}
"
git
!
"checkout -b activated-pod-commit
#{
options
[
:commit
]
}
"
end
end
def
download_branch
ensure_remote_branch_exists
(
options
[
:branch
])
git
%Q|clone "
#{
clone_url
}
" "
#{
target_path
}
"|
clone
(
clone_url
,
target_path
)
Dir
.
chdir
(
target_path
)
do
git
"remote add upstream '
#{
@url
}
'"
# we need to add the original url, not the cache url
git
"fetch -q upstream"
# refresh the branches
git
"checkout --track -b activated-pod-commit upstream/
#{
options
[
:branch
]
}
"
# create a new tracking branch
git
!
"remote add upstream '
#{
@url
}
'"
# we need to add the original url, not the cache url
git
!
"fetch -q upstream"
# refresh the branches
git
!
"checkout --track -b activated-pod-commit upstream/
#{
options
[
:branch
]
}
"
# create a new tracking branch
puts
"Just downloaded and checked out branch:
#{
options
[
:branch
]
}
from upstream
#{
clone_url
}
"
if
config
.
verbose?
end
end
def
clone
(
from
,
to
)
git!
%Q|clone "
#{
from
}
" "
#{
to
}
"|
end
end
class
GitHub
<
Git
...
...
lib/cocoapods/downloader/http.rb
View file @
c9dd6934
...
...
@@ -52,17 +52,17 @@ module Pod
end
def
download_file
(
full_filename
)
curl
"-L -o '
#{
full_filename
}
' '
#{
url
}
'"
curl
!
"-L -o '
#{
full_filename
}
' '
#{
url
}
'"
end
def
extract_with_type
(
full_filename
,
type
=
:zip
)
case
type
when
:zip
unzip
"'
#{
full_filename
}
' -d '
#{
target_path
}
'"
unzip
!
"'
#{
full_filename
}
' -d '
#{
target_path
}
'"
when
:tgz
tar
"xfz '
#{
full_filename
}
' -C '
#{
target_path
}
'"
tar
!
"xfz '
#{
full_filename
}
' -C '
#{
target_path
}
'"
when
:tar
tar
"xf '
#{
full_filename
}
' -C '
#{
target_path
}
'"
tar
!
"xf '
#{
full_filename
}
' -C '
#{
target_path
}
'"
else
raise
UnsupportedFileTypeError
.
new
"Unsupported file type:
#{
type
}
"
end
...
...
lib/cocoapods/downloader/mercurial.rb
View file @
c9dd6934
...
...
@@ -12,11 +12,11 @@ module Pod
end
def
download_head
hg
"clone
\"
#{
url
}
\"
\"
#{
target_path
}
\"
"
hg
!
"clone
\"
#{
url
}
\"
\"
#{
target_path
}
\"
"
end
def
download_revision
hg
"clone
\"
#{
url
}
\"
--rev '
#{
options
[
:revision
]
}
'
\"
#{
target_path
}
\"
"
hg
!
"clone
\"
#{
url
}
\"
--rev '
#{
options
[
:revision
]
}
'
\"
#{
target_path
}
\"
"
end
end
end
...
...
lib/cocoapods/downloader/subversion.rb
View file @
c9dd6934
...
...
@@ -4,11 +4,11 @@ module Pod
executable
:svn
def
download
svn
%|checkout "#{reference_url}" "#{target_path}"|
svn
!
%|checkout "#{reference_url}" "#{target_path}"|
end
def
download_head
svn
%|checkout "#{trunk_url}" "#{target_path}"|
svn
!
%|checkout "#{trunk_url}" "#{target_path}"|
end
def
reference_url
...
...
lib/cocoapods/executable.rb
View file @
c9dd6934
...
...
@@ -20,7 +20,7 @@ module Pod
def
executable
(
name
)
bin
=
`which
#{
name
}
`
.
strip
define_method
(
name
)
do
|
command
|
define_method
(
name
)
do
|
command
,
should_raise
=
false
|
if
bin
.
empty?
raise
Informative
,
"Unable to locate the executable `
#{
name
}
'"
end
...
...
@@ -33,9 +33,22 @@ module Pod
end
status
=
Open4
.
spawn
(
full_command
,
:stdout
=>
stdout
,
:stderr
=>
stderr
,
:status
=>
true
)
# TODO not sure that we should be silent in case of a failure.
puts
(
Config
.
instance
.
verbose?
?
' '
:
''
)
<<
"[!] Failed:
#{
full_command
}
"
.
red
unless
status
.
success?
||
Config
.
instance
.
silent?
stdout
.
join
(
"
\n
"
)
+
stderr
.
join
(
"
\n
"
)
# TODO will this suffice?
output
=
stdout
.
join
(
"
\n
"
)
+
stderr
.
join
(
"
\n
"
)
# TODO will this suffice?
unless
status
.
success?
if
should_raise
raise
Informative
,
"
#{
name
}
#{
command
}
\n\n
#{
output
}
"
else
puts
(
Config
.
instance
.
verbose?
?
' '
:
''
)
<<
"[!] Failed:
#{
full_command
}
"
.
red
unless
Config
.
instance
.
silent?
end
end
output
end
define_method
(
name
.
to_s
+
"!"
)
do
|
command
|
send
(
name
,
command
,
true
)
end
private
name
end
end
...
...
spec/functional/downloader/git_spec.rb
View file @
c9dd6934
...
...
@@ -108,7 +108,7 @@ module Pod
Downloader
::
Git
::
MAX_CACHE_SIZE
=
original_chace_size
end
x
it
"raises if it can't find the url"
do
it
"raises if it can't find the url"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
'find_me_if_you_can'
)
...
...
@@ -193,6 +193,7 @@ module Pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
@pod
.
root
.
rmtree
downloader
.
expects
(
:update_cache
).
never
downloader
.
download
end
...
...
spec/functional/downloader_spec.rb
View file @
c9dd6934
...
...
@@ -15,6 +15,14 @@ module Pod
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
end
it
"raises if it fails to download"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:hg
=>
"find me if you can"
,
:revision
=>
'46198bb3af96'
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
end
describe
"for Subversion"
do
...
...
@@ -45,6 +53,14 @@ module Pod
downloader
.
download_head
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'unintersting'
end
it
"raises if it fails to download"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:svn
=>
"find me if you can"
,
:revision
=>
'1'
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
end
...
...
@@ -61,6 +77,14 @@ module Pod
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
should
.
exist
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
read
.
strip
.
should
=~
/Google Search Ads iOS SDK/
end
it
"raises if it fails to download"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:http
=>
'find me if you can.zip'
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
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