From 7c015f9967b5ea592aba12a50971cd54060c92e5 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Thu, 19 Sep 2013 05:40:41 +0200 Subject: [PATCH] Don't assume that every repository has a remote that we can pull Fixes #1378 --- CHANGELOG.md | 4 ++++ lib/cocoapods/sources_manager.rb | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 166d554a33..2ca51345ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides * Added the `documentation_url` DSL attribute to the specifications. [#1273](https://github.com/CocoaPods/CocoaPods/pull/1273) +* Allow using local git based spec repositories which do not have a remote. + [Kyle Fuller](https://github.com/kylef) + [#1378](https://github.com/CocoaPods/CocoaPods/issues/1378) + ###### Bug Fixes * The search paths of vendored frameworks and libraries now are always diff --git a/lib/cocoapods/sources_manager.rb b/lib/cocoapods/sources_manager.rb index 2e9002e6e6..e938d36422 100644 --- a/lib/cocoapods/sources_manager.rb +++ b/lib/cocoapods/sources_manager.rb @@ -145,7 +145,7 @@ def update(source_name = nil, show_output = false) raise Informative, "The `#{source_name}` repo is not a git repo." unless git_repo?(specified_source.repo) sources = [specified_source] else - sources = aggregate.all.select { |source| git_repo?(source.repo) } + sources = aggregate.all.select { |source| git_repo?(source.repo) && has_git_remote?(source.repo) } end sources.each do |source| @@ -171,6 +171,17 @@ def git_repo?(dir) $?.exitstatus.zero? end + # Returns whether a source GIT repository has a remote + # + # @param [Pathname] dir + # The directory where the source is stored. + # + # @return [Bool] Wether the given GIT repository has a remote endpoint. + # + def has_git_remote?(dir) + ! Dir.chdir(dir) { next git!('remote') }.strip.empty? + end + # Checks the version information of the source with the given directory. # It raises if the source is not compatible and if there is CocoaPods # update it informs the user.