aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMike McQuaid2017-02-25 14:13:35 +0000
committerGitHub2017-02-25 14:13:35 +0000
commitd0a965e2aba096f02ea8cf886ac3abfd4c018f33 (patch)
tree8d502e9d17bc7dfa3ae4abf81745176f12cda37a /Library/Homebrew/dev-cmd
parent27d6644dfa99db5e1941cfb3d74c29b4cdaac9b1 (diff)
parent96a8f8f1727e3d6445d42570d287f4f7013d5ea1 (diff)
downloadbrew-d0a965e2aba096f02ea8cf886ac3abfd4c018f33.tar.bz2
Merge pull request #2107 from MikeMcQuaid/audit-version-aliases
audit: check for version aliases.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index ab7abf1e6..134965355 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -329,6 +329,27 @@ class FormulaAuditor
problem "File should end with a newline" unless text.trailing_newline?
+ versioned_formulae = Dir[formula.path.to_s.gsub(/\.rb$/, "@*.rb")]
+ needs_versioned_alias = !versioned_formulae.empty? &&
+ formula.tap &&
+ formula.aliases.grep(/.@\d/).empty?
+ if needs_versioned_alias
+ _, last_alias_version = File.basename(versioned_formulae.sort.reverse.first)
+ .gsub(/\.rb$/, "")
+ .split("@")
+ major, minor, = formula.version.to_s.split(".")
+ alias_name = if last_alias_version.split(".").length == 1
+ "#{formula.name}@#{major}"
+ else
+ "#{formula.name}@#{major}.#{minor}"
+ end
+ problem <<-EOS.undent
+ Formula has other versions so create an alias:
+ cd #{formula.tap.alias_dir}
+ ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
+ EOS
+ end
+
return unless @strict
present = audit_components
@@ -444,7 +465,8 @@ class FormulaAuditor
problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
end
- if @@aliases.include?(dep.name)
+ if @@aliases.include?(dep.name) &&
+ (core_formula? || !dep_f.versioned_formula?)
problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
end