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
b7baee96
Commit
b7baee96
authored
May 09, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Downloader::Git] Skip cache pull if ref is available.
parent
0d4dd44b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
git.rb
lib/cocoapods/downloader/git.rb
+25
-11
No files found.
lib/cocoapods/downloader/git.rb
View file @
b7baee96
...
...
@@ -23,15 +23,7 @@ module Pod
end
def
prepare_cache
return
if
config
.
git_cache_size
==
0
if
is_cache_valid?
puts
'->'
.
green
<<
" 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"
end
else
unless
cache_exist?
||
config
.
git_cache_size
==
0
puts
'->'
.
green
<<
" Creating cache git repo (
#{
cache_path
}
)"
if
config
.
verbose?
cache_path
.
rmtree
if
cache_path
.
exist?
cache_path
.
mkpath
...
...
@@ -55,7 +47,7 @@ module Pod
@cache_path
||=
caches_dir
+
"
#{
Digest
::
SHA1
.
hexdigest
(
url
.
to_s
)
}
"
end
def
is_cache_valid
?
def
cache_exist
?
cache_path
.
exist?
&&
origin_url
(
cache_path
)
==
url
end
...
...
@@ -77,11 +69,33 @@ module Pod
`du -cm`
.
split
(
"
\n
"
).
last
.
to_i
end
def
update_cache
return
if
config
.
git_cache_size
==
0
puts
'->'
.
green
<<
" 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"
end
end
def
ensure_ref_exists
(
ref
)
return
if
config
.
git_cache_size
==
0
Dir
.
chdir
(
cache_path
)
{
git
"rev-list --max-count=1
#{
ref
}
"
}
return
if
$?
==
0
# Skip pull if not needed
update_cache
Dir
.
chdir
(
cache_path
)
{
git
"rev-list --max-count=1
#{
ref
}
"
}
raise
Informative
,
"[!] Cache unable to find git reference `
#{
ref
}
' for `
#{
url
}
'."
.
red
unless
$?
==
0
end
def
download_head
update_cache
git
"clone '
#{
clone_url
}
' '
#{
target_path
}
'"
end
def
download_tag
ensure_ref_exists
(
options
[
:tag
])
Dir
.
chdir
(
target_path
)
do
git
"init"
git
"remote add origin '
#{
clone_url
}
'"
...
...
@@ -92,8 +106,8 @@ module Pod
end
def
download_commit
ensure_ref_exists
(
options
[
:commit
])
git
"clone '
#{
clone_url
}
' '
#{
target_path
}
'"
Dir
.
chdir
(
target_path
)
do
git
"checkout -b activated-pod-commit
#{
options
[
:commit
]
}
"
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