aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb200
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb10
-rw-r--r--Library/Homebrew/dev-cmd/edit.rb8
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb2
-rw-r--r--Library/Homebrew/dev-cmd/release-notes.rb8
-rw-r--r--Library/Homebrew/dev-cmd/tap-new.rb4
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb37
-rw-r--r--Library/Homebrew/dev-cmd/update-test.rb20
8 files changed, 115 insertions, 174 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index cb25ca794..aaac9c96b 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -307,25 +307,45 @@ class FormulaAuditor
unversioned_name = unversioned_formula.basename(".rb")
problem "#{formula} is versioned but no #{unversioned_name} formula exists"
end
- elsif ARGV.build_stable?
- 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}"
+ elsif ARGV.build_stable? &&
+ !(versioned_formulae = Dir[formula.path.to_s.gsub(/\.rb$/, "@*.rb")]).empty?
+ versioned_aliases = formula.aliases.grep(/.@\d/)
+ _, last_alias_version =
+ File.basename(versioned_formulae.sort.reverse.first)
+ .gsub(/\.rb$/, "").split("@")
+ major, minor, = formula.version.to_s.split(".")
+ alias_name_major = "#{formula.name}@#{major}"
+ alias_name_major_minor = "#{alias_name_major}.#{minor}"
+ alias_name = if last_alias_version.split(".").length == 1
+ alias_name_major
+ else
+ alias_name_major_minor
+ end
+ valid_alias_names = [alias_name_major, alias_name_major_minor]
+
+ if formula.tap && !formula.tap.core_tap?
+ valid_alias_names.map! { |a| "#{formula.tap}/#{a}" }
+ end
+
+ valid_versioned_aliases = versioned_aliases & valid_alias_names
+ invalid_versioned_aliases = versioned_aliases - valid_alias_names
+
+ if valid_versioned_aliases.empty?
+ if formula.tap
+ problem <<-EOS.undent
+ Formula has other versions so create a versioned alias:
+ cd #{formula.tap.alias_dir}
+ ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
+ EOS
else
- "#{formula.name}@#{major}.#{minor}"
+ problem "Formula has other versions so create an alias named #{alias_name}."
end
+ end
+
+ unless invalid_versioned_aliases.empty?
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}
+ Formula has invalid versioned aliases:
+ #{invalid_versioned_aliases.join("\n ")}
EOS
end
end
@@ -571,78 +591,7 @@ class FormulaAuditor
def audit_homepage
homepage = formula.homepage
- if homepage.nil? || homepage.empty?
- problem "Formula should have a homepage."
- return
- end
-
- unless homepage =~ %r{^https?://}
- problem "The homepage should start with http or https (URL is #{homepage})."
- end
-
- # Check for http:// GitHub homepage urls, https:// is preferred.
- # Note: only check homepages that are repo pages, not *.github.com hosts
- if homepage.start_with? "http://github.com/"
- problem "Please use https:// for #{homepage}"
- end
-
- # Savannah has full SSL/TLS support but no auto-redirect.
- # Doesn't apply to the download URLs, only the homepage.
- if homepage.start_with? "http://savannah.nongnu.org/"
- problem "Please use https:// for #{homepage}"
- end
-
- # Freedesktop is complicated to handle - It has SSL/TLS, but only on certain subdomains.
- # To enable https Freedesktop change the URL from http://project.freedesktop.org/wiki to
- # https://wiki.freedesktop.org/project_name.
- # "Software" is redirected to https://wiki.freedesktop.org/www/Software/project_name
- if homepage =~ %r{^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?}
- if homepage =~ /Software/
- problem "#{homepage} should be styled `https://wiki.freedesktop.org/www/Software/project_name`"
- else
- problem "#{homepage} should be styled `https://wiki.freedesktop.org/project_name`"
- end
- end
-
- # Google Code homepages should end in a slash
- if homepage =~ %r{^https?://code\.google\.com/p/[^/]+[^/]$}
- problem "#{homepage} should end with a slash"
- end
-
- # People will run into mixed content sometimes, but we should enforce and then add
- # exemptions as they are discovered. Treat mixed content on homepages as a bug.
- # Justify each exemptions with a code comment so we can keep track here.
- case homepage
- when %r{^http://[^/]*\.github\.io/},
- %r{^http://[^/]*\.sourceforge\.io/}
- problem "Please use https:// for #{homepage}"
- end
-
- if homepage =~ %r{^http://([^/]*)\.(sf|sourceforge)\.net(/|$)}
- problem "#{homepage} should be `https://#{$1}.sourceforge.io/`"
- end
-
- # There's an auto-redirect here, but this mistake is incredibly common too.
- # Only applies to the homepage and subdomains for now, not the FTP URLs.
- if homepage =~ %r{^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org}
- problem "Please use https:// for #{homepage}"
- end
-
- # Compact the above into this list as we're able to remove detailed notations, etc over time.
- case homepage
- when %r{^http://[^/]*\.apache\.org},
- %r{^http://packages\.debian\.org},
- %r{^http://wiki\.freedesktop\.org/},
- %r{^http://((?:www)\.)?gnupg\.org/},
- %r{^http://ietf\.org},
- %r{^http://[^/.]+\.ietf\.org},
- %r{^http://[^/.]+\.tools\.ietf\.org},
- %r{^http://www\.gnu\.org/},
- %r{^http://code\.google\.com/},
- %r{^http://bitbucket\.org/},
- %r{^http://(?:[^/]*\.)?archive\.org}
- problem "Please use https:// for #{homepage}"
- end
+ return if homepage.nil? || homepage.empty?
return unless @online
@@ -795,6 +744,15 @@ class FormulaAuditor
return if @new_formula
fv = FormulaVersions.new(formula)
+
+ previous_version_and_checksum = fv.previous_version_and_checksum("origin/master")
+ [:stable, :devel].each do |spec_sym|
+ next unless spec = formula.send(spec_sym)
+ next unless previous_version_and_checksum[spec_sym][:version] == spec.version
+ next if previous_version_and_checksum[spec_sym][:checksum] == spec.checksum
+ problem "#{spec_sym}: sha256 changed without the version also changing; please create an issue upstream to rule out malicious circumstances and to find out why the file changed."
+ end
+
attributes = [:revision, :version_scheme]
attributes_map = fv.version_attributes_map(attributes, "origin/master")
@@ -892,14 +850,6 @@ class FormulaAuditor
end
def audit_text
- if text =~ /system\s+['"]scons/
- problem "use \"scons *args\" instead of \"system 'scons', *args\""
- end
-
- if text =~ /system\s+['"]xcodebuild/
- problem %q(use "xcodebuild *args" instead of "system 'xcodebuild', *args")
- end
-
bin_names = Set.new
bin_names << formula.name
bin_names += formula.aliases
@@ -909,44 +859,16 @@ class FormulaAuditor
end
bin_names.each do |name|
["system", "shell_output", "pipe_output"].each do |cmd|
- if text =~ %r{(def test|test do).*(#{Regexp.escape HOMEBREW_PREFIX}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape name}[\s'"]}m
+ if text =~ %r{(def test|test do).*(#{Regexp.escape(HOMEBREW_PREFIX)}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]}m
problem %Q(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}")
end
end
end
-
- if text =~ /xcodebuild[ (]*["'*]*/ && !text.include?("SYMROOT=")
- problem 'xcodebuild should be passed an explicit "SYMROOT"'
- end
-
- if text.include? "Formula.factory("
- problem "\"Formula.factory(name)\" is deprecated in favor of \"Formula[name]\""
- end
-
- if text.include?("def plist") && !text.include?("plist_options")
- problem "Please set plist_options when using a formula-defined plist."
- end
-
- if text =~ /depends_on\s+['"]openssl['"]/ && text =~ /depends_on\s+['"]libressl['"]/
- problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)."
- end
-
- if text =~ /virtualenv_(create|install_with_resources)/ &&
- text =~ /resource\s+['"]setuptools['"]\s+do/
- problem "Formulae using virtualenvs do not need a `setuptools` resource."
- end
-
- if text =~ /system\s+['"]go['"],\s+['"]get['"]/
- problem "Formulae should not use `go get`. If non-vendored resources are required use `go_resource`s."
- end
-
- return unless text.include?('require "language/go"') && !text.include?("go_resource")
- problem "require \"language/go\" is unnecessary unless using `go_resource`s"
end
def audit_lines
text.without_patch.split("\n").each_with_index do |line, lineno|
- line_problems(line, lineno+1)
+ line_problems(line, lineno + 1)
end
end
@@ -1028,16 +950,19 @@ class FormulaAuditor
problem ":apr is deprecated. Usage should be \"apr-util\""
end
- if line =~ /depends_on :tex/
- problem ":tex is deprecated"
- end
+ problem ":tex is deprecated" if line =~ /depends_on :tex/
if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
problem "#{$2} modules should be vendored rather than use deprecated `depends_on \"#{$1}\" => :#{$2}#{$3}`"
end
- if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+.*(?<!\?[( ])['"](.+)['"]/
- problem "Dependency #{$1} should not use option #{$2}"
+ if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+(.*)/
+ dep = $1
+ $2.split(" ").map do |o|
+ break if ["if", "unless"].include?(o)
+ next unless o =~ /^\[?['"](.*)['"]/
+ problem "Dependency #{dep} should not use option #{$1}"
+ end
end
# Commented-out depends_on
@@ -1224,11 +1149,6 @@ class FormulaAuditor
problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
end
- def audit_caveats
- return unless formula.caveats.to_s.include?("setuid")
- problem "Don't recommend setuid in the caveats, suggest sudo instead."
- end
-
def audit_reverse_migration
# Only enforce for new formula being re-added to core and official taps
return unless @strict
@@ -1577,6 +1497,14 @@ class ResourceAuditor
problem "#{u} should be `https://search.maven.org/remotecontent?filepath=#{$1}`"
end
+ # Check pypi urls
+ if @strict
+ urls.each do |p|
+ next unless p =~ %r{^https?://pypi.python.org/(.*)}
+ problem "#{p} should be `https://files.pythonhosted.org/#{$1}`"
+ end
+ end
+
return unless @online
urls.each do |url|
next if !@strict && mirrors.include?(url)
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 8d3038a5a..d8aefc4c0 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -248,7 +248,7 @@ module Homebrew
mv "#{relocatable_tar_path}.gz", bottle_path
end
- if bottle_path.size > 1*1024*1024
+ if bottle_path.size > 1 * 1024 * 1024
ohai "Detecting if #{filename} is relocatable..."
end
@@ -314,8 +314,8 @@ module Homebrew
old_spec = f.bottle_specification
if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
- mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key|
- old_spec.send(key) != bottle.send(key)
+ mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key|
+ old_spec.send(key) == bottle.send(key)
end
mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
unless mismatches.empty?
@@ -382,9 +382,7 @@ module Homebrew
bottle = BottleSpecification.new
bottle.root_url bottle_hash["bottle"]["root_url"]
cellar = bottle_hash["bottle"]["cellar"]
- if cellar == "any" || cellar == "any_skip_relocation"
- cellar = cellar.to_sym
- end
+ cellar = cellar.to_sym if ["any", "any_skip_relocation"].include?(cellar)
bottle.cellar cellar
bottle.prefix bottle_hash["bottle"]["prefix"]
bottle.rebuild bottle_hash["bottle"]["rebuild"]
diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb
index df5bc0605..b3a319088 100644
--- a/Library/Homebrew/dev-cmd/edit.rb
+++ b/Library/Homebrew/dev-cmd/edit.rb
@@ -21,12 +21,12 @@ module Homebrew
# If no brews are listed, open the project root in an editor.
if ARGV.named.empty?
editor = File.basename which_editor
- if editor == "mate" || editor == "subl"
+ if ["mate", "subl"].include?(editor)
# If the user is using TextMate or Sublime Text,
# give a nice project view instead.
- exec_editor HOMEBREW_REPOSITORY+"bin/brew",
- HOMEBREW_REPOSITORY+"README.md",
- HOMEBREW_REPOSITORY+".gitignore",
+ exec_editor HOMEBREW_REPOSITORY/"bin/brew",
+ HOMEBREW_REPOSITORY/"README.md",
+ HOMEBREW_REPOSITORY/".gitignore",
*library_folders
else
exec_editor HOMEBREW_REPOSITORY
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index 9d08da95b..492898a47 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -14,7 +14,7 @@
#:
#: ~ The URL of a commit on GitHub
#:
-#: ~ A "https://bot.brew.sh/job/..." string specifying a testing job ID
+#: ~ A "https://jenkins.brew.sh/job/..." string specifying a testing job ID
#:
#: If `--bottle` is passed, handle bottles, pulling the bottle-update
#: commit and publishing files on Bintray.
diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb
index eb398fcfb..bd6363865 100644
--- a/Library/Homebrew/dev-cmd/release-notes.rb
+++ b/Library/Homebrew/dev-cmd/release-notes.rb
@@ -27,13 +27,13 @@ module Homebrew
.lines.grep(/Merge pull request/)
output.map! do |s|
- s.gsub(/.*Merge pull request #(\d+)[^>]*(>>)*/,
- "https://github.com/Homebrew/brew/pull/\\1")
+ s.gsub(%r{.*Merge pull request #(\d+) from ([^/]+)/[^>]*(>>)*},
+ "https://github.com/Homebrew/brew/pull/\\1 (@\\2)")
end
if ARGV.include?("--markdown")
output.map! do |s|
- /(.*\d)+ - (.*)/ =~ s
- "- [#{$2}](#{$1})"
+ /(.*\d)+ \(@(.+)\) - (.*)/ =~ s
+ "- [#{$3}](#{$1}) (@#{$2})"
end
end
diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb
index 48449e98d..dcb41265c 100644
--- a/Library/Homebrew/dev-cmd/tap-new.rb
+++ b/Library/Homebrew/dev-cmd/tap-new.rb
@@ -49,6 +49,10 @@ module Homebrew
env: OSX=10.12
osx_image: xcode8.3
rvm: system
+ cache:
+ directories:
+ - $HOME/.gem/ruby
+ - Library/Homebrew/vendor/bundle
before_install:
- export TRAVIS_COMMIT="$(git rev-parse --verify -q HEAD)"
diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index 72d6143fc..13f4d7b1e 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -59,10 +59,11 @@ module Homebrew
ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end
- Homebrew.install_gem_setup_path! "bundler"
- unless quiet_system("bundle", "check")
- system "bundle", "install"
- end
+ # TODO: unpin this version when this error no longer shows:
+ # bundler-1.15.0/lib/bundler/shared_helpers.rb:25:
+ # stack level too deep (SystemStackError)
+ Homebrew.install_gem_setup_path! "bundler", "1.14.6"
+ system "bundle", "install" unless quiet_system("bundle", "check")
parallel = true
@@ -79,20 +80,24 @@ module Homebrew
Dir.glob("test/**/*_spec.rb").reject { |p| p =~ %r{^test/vendor/bundle/} }
end
- opts = []
-
- if ENV["CI"]
- opts << "--combine-stderr"
- opts << "--serialize-stdout"
+ opts = if ENV["CI"]
+ %w[
+ --combine-stderr
+ --serialize-stdout
+ ]
+ else
+ %w[
+ --nice
+ ]
end
- args = [
- "--color",
- "-I", HOMEBREW_LIBRARY_PATH/"test",
- "--require", "spec_helper",
- "--format", "progress",
- "--format", "ParallelTests::RSpec::RuntimeLogger",
- "--out", "tmp/parallel_runtime_rspec.log"
+ args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
+ args += %W[
+ --color
+ --require spec_helper
+ --format progress
+ --format ParallelTests::RSpec::RuntimeLogger
+ --out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
]
args << "--seed" << ARGV.next if ARGV.include? "--seed"
diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb
index add05bc7c..aa7fe6a92 100644
--- a/Library/Homebrew/dev-cmd/update-test.rb
+++ b/Library/Homebrew/dev-cmd/update-test.rb
@@ -33,14 +33,20 @@ module Homebrew
elsif date = ARGV.value("before")
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
elsif ARGV.include?("--to-tag")
- previous_tag =
- Utils.popen_read("git", "tag", "--list", "--sort=-version:refname").lines[1]
- unless previous_tag
- safe_system "git", "fetch", "--tags", "--depth=1"
- previous_tag =
- Utils.popen_read("git", "tag", "--list", "--sort=-version:refname").lines[1]
+ tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
+ previous_tag = tags.lines[1]
+ previous_tag ||= begin
+ if (HOMEBREW_REPOSITORY/".git/shallow").exist?
+ safe_system "git", "fetch", "--tags", "--depth=1"
+ tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
+ elsif OS.linux?
+ tags = Utils.popen_read("git tag --list | sort -rV")
+ end
+ tags.lines[1]
end
- previous_tag.to_s.chomp
+ previous_tag = previous_tag.to_s.chomp
+ odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
+ previous_tag
else
Utils.popen_read("git", "rev-parse", "origin/master").chomp
end