-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) && git_remote_reachable?(source.repo) } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kylef
Contributor
|
||
end | ||
|
||
sources.each do |source| | ||
|
@@ -159,12 +159,24 @@ def update(source_name = nil, show_output = false) | |
end | ||
end | ||
|
||
# Returns whether a git repo's remote is reachable. | ||
# | ||
# @param [Pathname] dir | ||
# The directory where the source is stored. | ||
# | ||
# @return [Bool] Whether the given source's remote is reachable. | ||
# | ||
def git_remote_reachable?(dir) | ||
Dir.chdir(dir) { `git ls-remote` } | ||
$?.exitstatus.zero? | ||
end | ||
|
||
# Returns whether a source is a GIT repo. | ||
# | ||
# @param [Pathname] dir | ||
# The directory where the source is stored. | ||
# | ||
# @return [Bool] Wether the given source is a GIT repo. | ||
# @return [Bool] Whether the given source is a GIT repo. | ||
# | ||
def git_repo?(dir) | ||
Dir.chdir(dir) { `git rev-parse >/dev/null 2>&1` } | ||
|
@kapin every time when
pod install/update
will checkgit_remote_reachable
?but
git ls-remote
is very slow, so can this feature be switch by options?[jollychang@WilliamMBP CocoaPods]$ time git ls-remote
From git@github.com:CocoaPods/CocoaPods.git
real 0m10.546s