Skip to content

Commit

Permalink
[Git] Force a barebone repo for the cache.
Browse files Browse the repository at this point in the history
Closes #581.
Closes #569.
  • Loading branch information
fabiopelosin committed Oct 10, 2012
1 parent 62d8471 commit 5c10da1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
@@ -1,9 +1,11 @@
## Master

[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.15.1...master)
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.15.1...master)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.3.4...master)

###### Bug fixes
###### Enhancements

- The git cache now always uses a barebone repo.
[#581](https://github.com/CocoaPods/CocoaPods/pull/581)
- Added support for `.hh` headers.
[#576](https://github.com/CocoaPods/CocoaPods/pull/576)

Expand Down
22 changes: 10 additions & 12 deletions lib/cocoapods/downloader/git.rb
Expand Up @@ -105,7 +105,7 @@ def download_branch

# @!group Checking references

# @return [Bool] Wether a reference (SHA of tag)
# @return [Bool] Wether a reference (commit SHA or tag)
#
def ref_exists?(ref)
Dir.chdir(cache_path) { git "rev-list --max-count=1 #{ref}" }
Expand Down Expand Up @@ -172,8 +172,15 @@ def caches_size

# @return [Bool] Wether the cache exits.
#
# @note The previous implementation of the cache didn't use a barebone
# git repo. This method takes into account this fact and checks
# that the cache is actually a barebone repo. If the cache was not
# barebone it will be deleted and recreated.
#
def cache_exist?
cache_path.exist? && cache_origin_url(cache_path).to_s == url.to_s
cache_path.exist? &&
cache_origin_url(cache_path).to_s == url.to_s &&
Dir.chdir(cache_path) { git("config core.bare").chomp == "true" }
end

# @return [String] The origin URL of the cache with the given directory.
Expand All @@ -200,16 +207,7 @@ def create_cache
#
def update_cache
UI.section(" > Updating cache git repo (#{cache_path})",'',1) do
Dir.chdir(cache_path) do
if git("config core.bare").chomp == "true"
git! "remote update"
else
git! "reset --hard HEAD"
git! "clean -d -x -f"
git! "pull origin master"
git! "fetch --tags"
end
end
Dir.chdir(cache_path) { git! "remote update" }
end
end

Expand Down

0 comments on commit 5c10da1

Please sign in to comment.