aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMike McQuaid2017-02-26 20:48:36 +0000
committerMike McQuaid2017-02-26 20:48:36 +0000
commitc2a460ec6d857ba33c89174d8d93fcaa403c3717 (patch)
tree089045fec4c46fb74e3b48868e2b335497df7b84 /Library/Homebrew/dev-cmd
parentd3ae1cc264dc9eb9b602dd6aa21c4282dc049c79 (diff)
parentff93e1624b214c9b48731174a9135789fc3695a8 (diff)
downloadbrew-c2a460ec6d857ba33c89174d8d93fcaa403c3717.tar.bz2
Merge branch 'master' into filter_all_env_vars_932
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb170
-rw-r--r--Library/Homebrew/dev-cmd/boneyard-formula-pr.rb2
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb6
-rw-r--r--Library/Homebrew/dev-cmd/bump-formula-pr.rb51
-rw-r--r--Library/Homebrew/dev-cmd/create.rb9
-rw-r--r--Library/Homebrew/dev-cmd/formula.rb13
-rw-r--r--Library/Homebrew/dev-cmd/linkage.rb2
-rw-r--r--Library/Homebrew/dev-cmd/man.rb4
-rw-r--r--Library/Homebrew/dev-cmd/mirror.rb2
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb63
-rw-r--r--Library/Homebrew/dev-cmd/release-notes.rb6
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb48
-rw-r--r--Library/Homebrew/dev-cmd/update-test.rb8
13 files changed, 286 insertions, 98 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 88d9a535c..35d590b69 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1,4 +1,4 @@
-#: * `audit` [`--strict`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] [<formulae>]:
+#: * `audit` [`--strict`] [`--fix`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] [<formulae>]:
#: Check <formulae> for Homebrew coding style violations. This should be
#: run before submitting a new formula.
#:
@@ -7,6 +7,9 @@
#: If `--strict` is passed, additional checks are run, including RuboCop
#: style checks.
#:
+#: If `--fix` is passed, style violations will be
+#: automatically fixed using RuboCop's `--auto-correct` feature.
+#:
#: If `--online` is passed, additional slower checks that require a network
#: connection are run.
#:
@@ -36,6 +39,7 @@ require "cmd/search"
require "cmd/style"
require "date"
require "blacklist"
+require "digest"
module Homebrew
module_function
@@ -62,8 +66,9 @@ module Homebrew
end
if strict
+ options = { fix: ARGV.flag?("--fix"), realpath: true }
# Check style in a single batch run up front for performance
- style_results = check_style_json(files, realpath: true)
+ style_results = check_style_json(files, options)
end
ff.each do |f|
@@ -169,31 +174,64 @@ class FormulaAuditor
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
end
- def url_status_code(url, range: false, user_agent: :default)
- # The system Curl is too old and unreliable with HTTPS homepages on
- # Yosemite and below.
- return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
+ def self.check_http_content(url, user_agents: [:default])
+ return unless url.start_with? "http"
- extra_args = [
- "--connect-timeout", "15",
- "--output", "/dev/null",
- "--write-out", "%{http_code}"
- ]
- extra_args << "--range" << "0-0" if range
- extra_args << url
+ details = nil
+ user_agent = nil
+ user_agents.each do |ua|
+ details = http_content_headers_and_checksum(url, user_agent: ua)
+ user_agent = ua
+ break if details[:status].to_s.start_with?("2")
+ end
+
+ return "The URL #{url} is not reachable" unless details[:status]
+ unless details[:status].start_with? "2"
+ return "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
+ end
+
+ return unless url.start_with? "http:"
+
+ secure_url = url.sub "http", "https"
+ secure_details =
+ http_content_headers_and_checksum(secure_url, user_agent: user_agent)
+
+ if !details[:status].to_s.start_with?("2") ||
+ !secure_details[:status].to_s.start_with?("2")
+ return
+ end
+
+ etag_match = details[:etag] &&
+ details[:etag] == secure_details[:etag]
+ content_length_match =
+ details[:content_length] &&
+ details[:content_length] == secure_details[:content_length]
+ file_match = details[:file_hash] == secure_details[:file_hash]
+
+ return if !etag_match && !content_length_match && !file_match
+ "The URL #{url} could use HTTPS rather than HTTP"
+ end
+ def self.http_content_headers_and_checksum(url, user_agent: :default)
args = curl_args(
- extra_args: extra_args,
+ extra_args: ["--connect-timeout", "15", "--include", url],
show_output: true,
- user_agent: user_agent
+ user_agent: user_agent,
)
- retries = 3
- status_code = nil
- retries.times do
- status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
- break if status_code.start_with? "20"
+ output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
+
+ status_code = :unknown
+ while status_code == :unknown || status_code.to_s.start_with?("3")
+ headers, _, output = output.partition("\r\n\r\n")
+ status_code = headers[%r{HTTP\/.* (\d+)}, 1]
end
- status_code
+
+ {
+ status: status_code,
+ etag: headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2],
+ content_length: headers[/Content-Length: (\d+)/, 1],
+ file_hash: Digest::SHA256.digest(output),
+ }
end
def audit_style
@@ -291,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
@@ -406,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
@@ -459,6 +519,14 @@ class FormulaAuditor
end
def audit_conflicts
+ if formula.conflicts.any? && formula.versioned_formula?
+ problem <<-EOS
+ Versioned formulae should not use `conflicts_with`.
+ Use `keg_only :versioned_formula` instead.
+ EOS
+ return
+ end
+
formula.conflicts.each do |c|
begin
Formulary.factory(c.name)
@@ -481,6 +549,10 @@ class FormulaAuditor
next unless @strict
+ if o.name == "universal" && !Formula["wine"].recursive_dependencies.map(&:name).include?(formula.name)
+ problem "macOS has been 64-bit only since 10.6 so universal options are deprecated."
+ end
+
if o.name !~ /with(out)?-/ && o.name != "c++11" && o.name != "universal"
problem "Options should begin with with/without. Migrate '--#{o.name}' with `deprecated_option`."
end
@@ -493,7 +565,7 @@ class FormulaAuditor
return unless @new_formula
return if formula.deprecated_options.empty?
- return if formula.name.include?("@")
+ return if formula.versioned_formula?
problem "New formulae should not use `deprecated_option`."
end
@@ -569,10 +641,16 @@ class FormulaAuditor
# 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.
- if homepage =~ %r{^http://[^/]*github\.io/}
+ 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}
@@ -597,9 +675,13 @@ class FormulaAuditor
return unless @online
- status_code = url_status_code(homepage, user_agent: :browser)
- return if status_code.start_with? "20"
- problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
+ # The system Curl is too old and unreliable with HTTPS homepages on
+ # Yosemite and below.
+ return unless DevelopmentTools.curl_handles_most_https_homepages?
+ if http_content_problem = FormulaAuditor.check_http_content(homepage,
+ user_agents: [:browser, :default])
+ problem http_content_problem
+ end
end
def audit_bottle_spec
@@ -649,11 +731,11 @@ class FormulaAuditor
%w[Stable Devel HEAD].each do |name|
next unless spec = formula.send(name.downcase)
- ra = ResourceAuditor.new(spec).audit
+ ra = ResourceAuditor.new(spec, online: @online, strict: @strict).audit
problems.concat ra.problems.map { |problem| "#{name}: #{problem}" }
spec.resources.each_value do |resource|
- ra = ResourceAuditor.new(resource).audit
+ ra = ResourceAuditor.new(resource, online: @online, strict: @strict).audit
problems.concat ra.problems.map { |problem|
"#{name} resource #{resource.name.inspect}: #{problem}"
}
@@ -680,6 +762,7 @@ class FormulaAuditor
unstable_whitelist = %w[
aalib 1.4rc5
+ angolmois 2.0.0alpha2
automysqlbackup 3.0-rc6
aview 1.3.0rc1
distcc 3.2rc1
@@ -687,6 +770,8 @@ class FormulaAuditor
ftgl 2.1.3-rc5
hidapi 0.8.0-rc1
libcaca 0.99b19
+ nethack4 4.3.0-beta2
+ opensyobon 1.0rc2
premake 4.4-beta5
pwnat 0.3-beta
pxz 4.999.9
@@ -839,7 +924,7 @@ class FormulaAuditor
end
end
- if text =~ /xcodebuild[ (]["'*]/ && !text.include?("SYMROOT=")
+ if text =~ /xcodebuild[ (]*["'*]*/ && !text.include?("SYMROOT=")
problem 'xcodebuild should be passed an explicit "SYMROOT"'
end
@@ -1200,7 +1285,7 @@ class ResourceAuditor
attr_reader :problems
attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name
- def initialize(resource)
+ def initialize(resource, options = {})
@name = resource.name
@version = resource.version
@checksum = resource.checksum
@@ -1208,6 +1293,8 @@ class ResourceAuditor
@mirrors = resource.mirrors
@using = resource.using
@specs = resource.specs
+ @online = options[:online]
+ @strict = options[:strict]
@problems = []
end
@@ -1332,6 +1419,7 @@ class ResourceAuditor
%r{^http://(?:[^/]*\.)?bintray\.com/},
%r{^http://tools\.ietf\.org/},
%r{^http://launchpad\.net/},
+ %r{^http://github\.com/},
%r{^http://bitbucket\.org/},
%r{^http://anonscm\.debian\.org/},
%r{^http://cpan\.metacpan\.org/},
@@ -1463,6 +1551,26 @@ class ResourceAuditor
next unless u =~ %r{https?://(?:central|repo\d+)\.maven\.org/maven2/(.+)$}
problem "#{u} should be `https://search.maven.org/remotecontent?filepath=#{$1}`"
end
+
+ return unless @online
+ urls.each do |url|
+ next if !@strict && mirrors.include?(url)
+
+ strategy = DownloadStrategyDetector.detect(url, using)
+ if strategy <= CurlDownloadStrategy && !url.start_with?("file")
+ if http_content_problem = FormulaAuditor.check_http_content(url)
+ problem http_content_problem
+ end
+ elsif strategy <= GitDownloadStrategy
+ unless Utils.git_remote_exists url
+ problem "The URL #{url} is not a valid git URL"
+ end
+ elsif strategy <= SubversionDownloadStrategy
+ unless Utils.svn_remote_exists url
+ problem "The URL #{url} is not a valid svn URL"
+ end
+ end
+ end
end
def problem(text)
diff --git a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
index 3066d2ee6..7531ef9cf 100644
--- a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
@@ -1,5 +1,5 @@
#: @hide_from_man_page
-#: * `boneyard-formula-pr` [`--dry-run`] [`--local`] [`--reason=<reason>`] <formula-name> :
+#: * `boneyard-formula-pr` [`--dry-run`] [`--local`] [`--reason=<reason>`] <formula> :
#: Creates a pull request to boneyard a formula.
#:
#: If `--dry-run` is passed, print what would be done rather than doing it.
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 9618cf412..91bdcba93 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -1,6 +1,5 @@
-#: * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=<root_url>`] [`--force-core-tap`]:
+#: * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=`<URL>] [`--force-core-tap`]:
#: * `bottle` `--merge` [`--no-commit`] [`--keep-old`] [`--write`]:
-#:
#: Generate a bottle (binary package) from a formula installed with
#: `--build-bottle`.
@@ -435,6 +434,7 @@ module Homebrew
else
string = s.sub!(
/(
+ (\ {2}\#[^\n]*\n)* # comments
\ {2}( # two spaces at the beginning
(url|head)\ ['"][\S\ ]+['"] # url or head with a string
(
@@ -442,7 +442,7 @@ module Homebrew
(\n^\ {3}[\S\ ]+$)* # options can be in multiple lines
)?|
(homepage|desc|sha1|sha256|version|mirror)\ ['"][\S\ ]+['"]| # specs with a string
- rebuild\ \d+ # rebuild with a number
+ revision\ \d+ # revision with a number
)\n+ # multiple empty lines
)+
/mx, '\0' + output + "\n"
diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
index 68bf32d0b..6c7b7d5b5 100644
--- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -1,8 +1,7 @@
-#: * `bump-formula-pr` [`--devel`] [`--dry-run`] [`--audit`|`--strict`] [`--message=`<message>] `--url=`<url> `--sha256=`<sha-256> <formula>:
-#: * `bump-formula-pr` [`--devel`] [`--dry-run`] [`--audit`|`--strict`] [`--message=`<message>] `--tag=`<tag> `--revision=`<revision> <formula>:
-#: Creates a pull request to update the formula with a new url or a new tag.
+#: * `bump-formula-pr` [`--devel`] [`--dry-run` [`--write`]] [`--audit`|`--strict`] [`--mirror=`<URL>] [`--version=`<version>] [`--message=`<message>] (`--url=`<URL> `--sha256=`<sha-256>|`--tag=`<tag> `--revision=`<revision>) <formula>:
+#: Creates a pull request to update the formula with a new URL or a new tag.
#:
-#: If a <url> is specified, the <sha-256> checksum of the new download must
+#: If a <URL> is specified, the <sha-256> checksum of the new download must
#: also be specified. A best effort to determine the <sha-256> and <formula>
#: name will be made if either or both values are not supplied by the user.
#:
@@ -21,17 +20,17 @@
#:
#: If `--strict` is passed, run `brew audit --strict` before opening the PR.
#:
-#: If `--mirror=`<url> is passed, use the value as a mirror url.
+#: If `--mirror=`<URL> is passed, use the value as a mirror URL.
#:
#: If `--version=`<version> is passed, use the value to override the value
-#: parsed from the url or tag. Note that `--version=0` can be used to delete
+#: parsed from the URL or tag. Note that `--version=0` can be used to delete
#: an existing `version` override from a formula if it has become redundant.
#:
#: If `--message=`<message> is passed, append <message> to the default PR
#: message.
#:
#: Note that this command cannot be used to transition a formula from a
-#: url-and-sha256 style specification into a tag-and-revision style
+#: URL-and-sha256 style specification into a tag-and-revision style
#: specification, nor vice versa. It must use whichever style specification
#: the preexisting formula already uses.
@@ -78,8 +77,44 @@ module Homebrew
end
end
+ def fetch_pull_requests(formula)
+ GitHub.issues_for_formula(formula.name, tap: formula.tap).select do |pr|
+ pr["html_url"].include?("/pull/") &&
+ /(^|\s)#{Regexp.quote(formula.name)}(:|\s|$)/i =~ pr["title"]
+ end
+ rescue GitHub::RateLimitExceededError => e
+ opoo e.message
+ []
+ end
+
+ def check_for_duplicate_pull_requests(formula)
+ pull_requests = fetch_pull_requests(formula)
+ return unless pull_requests && !pull_requests.empty?
+ duplicates_message = <<-EOS.undent
+ These open pull requests may be duplicates:
+ #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
+ EOS
+ error_message = "Duplicate PRs should not be opened. Use --force to override this error."
+ if ARGV.force? && !ARGV.flag?("--quiet")
+ opoo duplicates_message
+ elsif !ARGV.force? && ARGV.flag?("--quiet")
+ odie error_message
+ elsif !ARGV.force?
+ odie <<-EOS.undent
+ #{duplicates_message.chomp}
+ #{error_message}
+ EOS
+ end
+ end
+
def bump_formula_pr
formula = ARGV.formulae.first
+
+ if formula
+ check_for_duplicate_pull_requests(formula)
+ checked_for_duplicates = true
+ end
+
new_url = ARGV.value("url")
if new_url && !formula
is_devel = ARGV.include?("--devel")
@@ -101,6 +136,8 @@ module Homebrew
end
odie "No formula found!" unless formula
+ check_for_duplicate_pull_requests(formula) unless checked_for_duplicates
+
requested_spec, formula_spec = if ARGV.include?("--devel")
devel_message = " (devel)"
[:devel, formula.devel]
diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb
index 07dd1b322..9c58dc71a 100644
--- a/Library/Homebrew/dev-cmd/create.rb
+++ b/Library/Homebrew/dev-cmd/create.rb
@@ -3,8 +3,7 @@
#: Homebrew will attempt to automatically derive the formula name
#: and version, but if it fails, you'll have to make your own template. The `wget`
#: formula serves as a simple example. For the complete API have a look at
-#:
-#: <http://www.rubydoc.info/github/Homebrew/brew/master/Formula>
+#: <http://www.rubydoc.info/github/Homebrew/brew/master/Formula>.
#:
#: If `--autotools` is passed, create a basic template for an Autotools-style build.
#: If `--cmake` is passed, create a basic template for a CMake-style build.
@@ -142,12 +141,10 @@ class FormulaCreator
def generate!
raise "#{path} already exists" if path.exist?
- if version.nil?
+ if version.nil? || version.null?
opoo "Version cannot be determined from URL."
puts "You'll need to add an explicit 'version' to the formula."
- end
-
- if fetch? && version
+ elsif fetch?
r = Resource.new
r.url(url)
r.version(version)
diff --git a/Library/Homebrew/dev-cmd/formula.rb b/Library/Homebrew/dev-cmd/formula.rb
new file mode 100644
index 000000000..67d11edce
--- /dev/null
+++ b/Library/Homebrew/dev-cmd/formula.rb
@@ -0,0 +1,13 @@
+#: * `formula` <formula>:
+#: Display the path where <formula> is located.
+
+require "formula"
+
+module Homebrew
+ module_function
+
+ def formula
+ raise FormulaUnspecifiedError if ARGV.named.empty?
+ ARGV.resolved_formulae.each { |f| puts f.path }
+ end
+end
diff --git a/Library/Homebrew/dev-cmd/linkage.rb b/Library/Homebrew/dev-cmd/linkage.rb
index 44e0f224e..e4da827f2 100644
--- a/Library/Homebrew/dev-cmd/linkage.rb
+++ b/Library/Homebrew/dev-cmd/linkage.rb
@@ -1,4 +1,4 @@
-#: * `linkage` [`--test`] [`--reverse`] <formula-name>:
+#: * `linkage` [`--test`] [`--reverse`] <formula>:
#: Checks the library links of an installed formula.
#:
#: Only works on installed formulae. An error is raised if it is run on
diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb
index 64c970453..581db38ca 100644
--- a/Library/Homebrew/dev-cmd/man.rb
+++ b/Library/Homebrew/dev-cmd/man.rb
@@ -23,10 +23,10 @@ module Homebrew
if ARGV.flag? "--link"
odie "`brew man --link` is now done automatically by `brew update`."
- else
- regenerate_man_pages
end
+ regenerate_man_pages
+
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/brew.1.html", "manpages"
puts "No changes to manpage output detected."
elsif ARGV.include?("--fail-if-changed")
diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb
index bd5868726..10811493c 100644
--- a/Library/Homebrew/dev-cmd/mirror.rb
+++ b/Library/Homebrew/dev-cmd/mirror.rb
@@ -1,5 +1,5 @@
#: @hide_from_man_page
-#: * `mirror` [`--test`] <formula-name> [<formula-name> ...]:
+#: * `mirror` [`--test`] <formulae>:
#: Reuploads the stable URL for a formula to Bintray to use it as a mirror.
module Homebrew
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index f7006baaa..98a62e578 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -1,33 +1,42 @@
-#: `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] <patch-source> [<patch-source>]
-#:
+#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] <patch-source> [<patch-source>]:
#: Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
#: Optionally, installs the formulae changed by the patch.
#:
#: Each <patch-source> may be one of:
-#: * The ID number of a PR (Pull Request) in the homebrew/core GitHub
+#:
+#: ~ The ID number of a PR (pull request) in the homebrew/core GitHub
#: repository
-#: * The URL of a PR on GitHub, using either the web page or API URL
+#:
+#: ~ The URL of a PR on GitHub, using either the web page or API URL
#: formats. In this form, the PR may be on Homebrew/brew,
#: Homebrew/homebrew-core or any tap.
-#: * The URL of a commit on GitHub
-#: * A "http://bot.brew.sh/job/..." string specifying a testing job ID
#:
-#: If `--bottle` was passed, handle bottles, pulling the bottle-update
-#: commit and publishing files on Bintray.
-#: If `--bump` was passed, for one-formula PRs, automatically reword
-#: commit message to our preferred format.
-#: If `--clean` was passed, do not rewrite or otherwise modify the
-#: commits found in the pulled PR.
-#: If `--ignore-whitespace` was passed, silently ignore whitespace
-#: discrepancies when applying diffs.
-#: If `--resolve` was passed, when a patch fails to apply, leave in
-#: progress and allow user to
-#: resolve, instead of aborting.
-#: If `--branch-okay` was passed, do not warn if pulling to a branch
-#: besides master (useful for testing).
-#: If `--no-pbcopy` was passed, do not copy anything to the system
-# clipboard.
-#: If `--no-publish` was passed, do not publish bottles to Bintray.
+#: ~ The URL of a commit on GitHub
+#:
+#: ~ A "http://bot.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.
+#:
+#: If `--bump` is passed, for one-formula PRs, automatically reword
+#: commit message to our preferred format.
+#:
+#: If `--clean` is passed, do not rewrite or otherwise modify the
+#: commits found in the pulled PR.
+#:
+#: If `--ignore-whitespace` is passed, silently ignore whitespace
+#: discrepancies when applying diffs.
+#:
+#: If `--resolve` is passed, when a patch fails to apply, leave in
+#: progress and allow user to resolve, instead of aborting.
+#:
+#: If `--branch-okay` is passed, do not warn if pulling to a branch
+#: besides master (useful for testing).
+#:
+#: If `--no-pbcopy` is passed, do not copy anything to the system
+#: clipboard.
+#:
+#: If `--no-publish` is passed, do not publish bottles to Bintray.
require "net/http"
require "net/https"
@@ -248,7 +257,6 @@ module Homebrew
changed_formulae_names.each do |name|
f = Formula[name]
next if f.bottle_unneeded? || f.bottle_disabled?
- ohai "Publishing on Bintray: #{f.name} #{f.pkg_version}"
publish_bottle_file_on_bintray(f, bintray_creds)
published << f.full_name
end
@@ -377,7 +385,7 @@ module Homebrew
subject_strs << "remove stable"
formula_name_str += ":" # just for cosmetics
else
- subject_strs << formula.version.to_s
+ subject_strs << new[:stable]
end
end
if old[:devel] != new[:devel]
@@ -388,7 +396,7 @@ module Homebrew
formula_name_str += ":" # just for cosmetics
end
else
- subject_strs << "#{formula.devel.version} (devel)"
+ subject_strs << "#{new[:devel]} (devel)"
end
end
subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}"
@@ -408,7 +416,12 @@ module Homebrew
if info.nil?
raise "Failed publishing bottle: failed reading formula info for #{f.full_name}"
end
+ unless info.bottle_info_any
+ opoo "No bottle defined in formula #{package}"
+ return
+ end
version = info.pkg_version
+ ohai "Publishing on Bintray: #{package} #{version}"
curl "-w", '\n', "--silent", "--fail",
"-u#{creds[:user]}:#{creds[:key]}", "-X", "POST",
"-H", "Content-Type: application/json",
diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb
index 919243764..eb398fcfb 100644
--- a/Library/Homebrew/dev-cmd/release-notes.rb
+++ b/Library/Homebrew/dev-cmd/release-notes.rb
@@ -1,7 +1,7 @@
-#: * `release-notes` [<previous_tag>] [<end_ref>]:
+#: * `release-notes` [`--markdown`] [<previous_tag>] [<end_ref>]:
#: Output the merged pull requests on Homebrew/brew between two Git refs.
-#: If no `previous_tag` is provided it defaults to the newest tag.
-#: If no `end_ref` is provided it defaults to `origin/master`.
+#: If no <previous_tag> is provided it defaults to the newest tag.
+#: If no <end_ref> is provided it defaults to `origin/master`.
#:
#: If `--markdown` is passed, output as a Markdown list.
diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index b4f3c2d40..0c8621a01 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -1,4 +1,4 @@
-#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script/test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
+#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script>`:`<test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
#: Run Homebrew's unit and integration tests.
require "fileutils"
@@ -7,10 +7,21 @@ require "tap"
module Homebrew
module_function
+ def run_tests(executable, files, args = [])
+ opts = []
+ opts << "--serialize-stdout" if ENV["CI"]
+
+ system "bundle", "exec", executable, *opts, "--", *args, "--", *files
+
+ return if $?.success?
+ Homebrew.failed = true
+ end
+
def tests
HOMEBREW_LIBRARY_PATH.cd do
ENV.delete "HOMEBREW_VERBOSE"
ENV.delete "VERBOSE"
+ ENV.delete("HOMEBREW_CASK_OPTS")
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["TESTOPTS"] = "-v" if ARGV.verbose?
@@ -34,6 +45,7 @@ module Homebrew
%w[AUTHOR COMMITTER].each do |role|
ENV["GIT_#{role}_NAME"] = "brew tests"
ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
+ ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end
Homebrew.install_gem_setup_path! "bundler"
@@ -44,27 +56,35 @@ module Homebrew
# Make it easier to reproduce test runs.
ENV["SEED"] = ARGV.next if ARGV.include? "--seed"
- files = Dir.glob("test/**/*_test.rb")
- .reject { |p| !OS.mac? && p.start_with?("test/os/mac/") }
- .reject { |p| p.start_with?("test/vendor/bundle/") }
-
- opts = []
- opts << "--serialize-stdout" if ENV["CI"]
+ files = Dir.glob("test/**/*_{spec,test}.rb")
+ .reject { |p| !OS.mac? && p =~ %r{^test/(os/mac|cask)(/.*|_(test|spec)\.rb)$} }
- args = []
- args << "--trace" if ARGV.include? "--trace"
+ test_args = []
+ test_args << "--trace" if ARGV.include? "--trace"
if ARGV.value("only")
test_name, test_method = ARGV.value("only").split(":", 2)
- files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_test.rb")
- args << "--name=test_#{test_method}" if test_method
+ files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_{spec,test}.rb")
+ test_args << "--name=test_#{test_method}" if test_method
end
- args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] }
+ test_files = files.select { |p| p.end_with?("_test.rb") }
+ spec_files = files.select { |p| p.end_with?("_spec.rb") }
+
+ test_args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] }
+ run_tests "parallel_test", test_files, test_args
- system "bundle", "exec", "parallel_test", *opts, "--", *args, "--", *files
+ spec_args = [
+ "--color",
+ "-I", HOMEBREW_LIBRARY_PATH/"test",
+ "--require", "spec_helper",
+ "--format", "progress",
+ "--format", "ParallelTests::RSpec::RuntimeLogger",
+ "--out", "tmp/parallel_runtime_rspec.log"
+ ]
+ spec_args << "--tag" << "~needs_macos" unless OS.mac?
- Homebrew.failed = !$?.success?
+ run_tests "parallel_rspec", spec_files, spec_args
if (fs_leak_log = HOMEBREW_LIBRARY_PATH/"tmp/fs_leak.log").file?
fs_leak_log_content = fs_leak_log.read
diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb
index 3b8dc11f9..9704426dd 100644
--- a/Library/Homebrew/dev-cmd/update-test.rb
+++ b/Library/Homebrew/dev-cmd/update-test.rb
@@ -1,14 +1,14 @@
-#: * `update-test` [`--commit=<commit>`] [`--before=<date>`] [`--keep-tmp`]:
+#: * `update-test` [`--commit=`<commit>] [`--before=`<date>] [`--keep-tmp`]:
#: Runs a test of `brew update` with a new repository clone.
#:
#: If no arguments are passed, use `origin/master` as the start commit.
#:
-#: If `--commit=<commit>` is passed, use `<commit>` as the start commit.
+#: If `--commit=`<commit> is passed, use <commit> as the start commit.
#:
-#: If `--before=<date>` is passed, use the commit at `<date>` as the
+#: If `--before=`<date> is passed, use the commit at <date> as the
#: start commit.
#:
-#: If `--to-tag` is passed, set HOMEBREW_UPDATE_TO_TAG to test updating
+#: If `--to-tag` is passed, set `HOMEBREW_UPDATE_TO_TAG` to test updating
#: between tags.
#:
#: If `--keep-tmp` is passed, retain the temporary directory containing