Skip to content
Browse files

[Git] Force a barebone repo for the cache.

Closes #581.
Closes #569.
  • Loading branch information...
1 parent 62d8471 commit 5c10da1b6abb238fba8364fd0964c68a030c6b0e @fabiopelosin fabiopelosin committed Oct 10, 2012
Showing with 14 additions and 14 deletions.
  1. +4 −2 CHANGELOG.md
  2. +10 −12 lib/cocoapods/downloader/git.rb
View
6 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)
View
22 lib/cocoapods/downloader/git.rb
@@ -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}" }
@@ -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.
@@ -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

0 comments on commit 5c10da1

Please sign in to comment.
Something went wrong with that request. Please try again.