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
4bdb17b1
Commit
4bdb17b1
authored
Sep 18, 2012
by
Eloy Durán
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #514 from raylillywhite/master
Update git repo cache if branch isn't found
parents
a2a9eab5
33509e01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
3 deletions
+50
-3
git.rb
lib/cocoapods/downloader/git.rb
+9
-3
git_spec.rb
spec/functional/downloader/git_spec.rb
+41
-0
No files found.
lib/cocoapods/downloader/git.rb
View file @
4bdb17b1
...
...
@@ -79,6 +79,7 @@ module Pod
git!
"reset --hard HEAD"
git!
"clean -d -x -f"
git!
"pull origin master"
git!
"fetch"
git!
"fetch --tags"
end
end
...
...
@@ -95,10 +96,15 @@ module Pod
raise
Informative
,
"[!] Cache unable to find git reference `
#{
ref
}
' for `
#{
url
}
'."
.
red
unless
ref_exists?
(
ref
)
end
def
ensure_remote_branch_exists
(
branch
)
def
branch_exists?
(
branch
)
Dir
.
chdir
(
cache_path
)
{
git
"branch -r | grep
#{
branch
}
$"
}
# check for remote branch and do suffix matching ($ anchor)
return
if
$?
==
0
raise
Informative
,
"[!] Cache unable to find git reference `
#{
branch
}
' for `
#{
url
}
' (
#{
$?
}
)."
.
red
$?
==
0
end
def
ensure_remote_branch_exists
(
branch
)
return
if
branch_exists?
(
branch
)
update_cache
raise
Informative
,
"[!] Cache unable to find git reference `
#{
branch
}
' for `
#{
url
}
' (
#{
$?
}
)."
.
red
unless
branch_exists?
(
branch
)
end
def
download_head
...
...
spec/functional/downloader/git_spec.rb
View file @
4bdb17b1
...
...
@@ -197,6 +197,47 @@ module Pod
downloader
.
expects
(
:update_cache
).
never
downloader
.
download
end
it
"updates the cache if the branch is not available"
do
# create the origin repo and the cache
tmp_repo_path
=
temporary_directory
+
'banana-lib-source'
`git clone
#{
fixture
(
'banana-lib'
)
}
#{
tmp_repo_path
}
`
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
tmp_repo_path
,
:branch
=>
'master'
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
# make a new branch in the origin
branch
=
'test'
Dir
.
chdir
(
tmp_repo_path
)
do
`touch test.txt`
`git checkout -b
#{
branch
}
>/dev/null 2>&1`
`git add test.txt`
`git commit -m 'test'`
end
# require the new branch
pod
=
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Platform
.
ios
)
pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
tmp_repo_path
,
:branch
=>
branch
)
downloader
=
Downloader
.
for_pod
(
pod
)
downloader
.
download
(
pod
.
root
+
'test.txt'
).
should
.
exist?
end
it
"doesn't update the cache if the branch is available"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:branch
=>
'master'
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
@pod
.
root
.
rmtree
downloader
.
expects
(
:update_cache
).
never
downloader
.
download
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