aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/download_strategy.rb
diff options
context:
space:
mode:
authorMarkus Reiter2016-09-23 22:02:23 +0200
committerMarkus Reiter2016-09-24 12:24:35 +0200
commit58e36c73193befb57d351344cea2a4a33fef850d (patch)
tree3d26751835440341e5a42a189cf580e6253785df /Library/Homebrew/download_strategy.rb
parentbbc3f1c3a852e6cfd26a7a7c333092fae0520eb4 (diff)
downloadbrew-58e36c73193befb57d351344cea2a4a33fef850d.tar.bz2
Fix Style/GuardClause.
Diffstat (limited to 'Library/Homebrew/download_strategy.rb')
-rw-r--r--Library/Homebrew/download_strategy.rb47
1 files changed, 23 insertions, 24 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index b852c1d5f..687e14396 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -158,14 +158,13 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
version.update_commit(last_commit) if head?
- if @ref_type == :tag && @revision && current_revision
- unless current_revision == @revision
- raise <<-EOS.undent
- #{@ref} tag should be #{@revision}
- but is actually #{current_revision}
- EOS
- end
- end
+ return unless @ref_type == :tag
+ return unless @revision && current_revision
+ return if current_revision == @revision
+ raise <<-EOS.undent
+ #{@ref} tag should be #{@revision}
+ but is actually #{current_revision}
+ EOS
end
def fetch_last_commit
@@ -336,14 +335,14 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
rescue ErrorDuringExecution
# 33 == range not supported
# try wiping the incomplete download and retrying once
- if $?.exitstatus == 33 && had_incomplete_download
- ohai "Trying a full download"
- temporary_path.unlink
- had_incomplete_download = false
- retry
- else
+ unless $?.exitstatus == 33 && had_incomplete_download
raise CurlDownloadStrategyError, @url
end
+
+ ohai "Trying a full download"
+ temporary_path.unlink
+ had_incomplete_download = false
+ retry
end
ignore_interrupts { temporary_path.rename(cached_location) }
end
@@ -717,12 +716,12 @@ class GitDownloadStrategy < VCSDownloadStrategy
end
def update_repo
- if @ref_type == :branch || !ref?
- if !shallow_clone? && shallow_dir?
- quiet_safe_system "git", "fetch", "origin", "--unshallow"
- else
- quiet_safe_system "git", "fetch", "origin"
- end
+ return unless @ref_type == :branch || !ref?
+
+ if !shallow_clone? && shallow_dir?
+ quiet_safe_system "git", "fetch", "origin", "--unshallow"
+ else
+ quiet_safe_system "git", "fetch", "origin"
end
end
@@ -798,10 +797,10 @@ end
class GitHubGitDownloadStrategy < GitDownloadStrategy
def initialize(name, resource)
super
- if @url =~ %r{^https?://github\.com/([^/]+)/([^/]+)\.git$}
- @user = $1
- @repo = $2
- end
+
+ return unless %r{^https?://github\.com/(?<user>[^/]+)/(?<repo>[^/]+)\.git$} =~ @url
+ @user = user
+ @repo = repo
end
def github_last_commit