audit: add --online flag.
Also add it to the manpage and brew-test-bot. Closes Homebrew/homebrew#41516. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
b11ae2abdc
commit
3ac6005931
@ -18,6 +18,8 @@ module Homebrew
|
|||||||
style
|
style
|
||||||
end
|
end
|
||||||
|
|
||||||
|
online = ARGV.include? "--online"
|
||||||
|
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ module Homebrew
|
|||||||
output_header = !strict
|
output_header = !strict
|
||||||
|
|
||||||
ff.each do |f|
|
ff.each do |f|
|
||||||
fa = FormulaAuditor.new(f, :strict => strict)
|
fa = FormulaAuditor.new(f, :strict => strict, :online => online)
|
||||||
fa.audit
|
fa.audit
|
||||||
|
|
||||||
unless fa.problems.empty?
|
unless fa.problems.empty?
|
||||||
@ -131,6 +133,7 @@ class FormulaAuditor
|
|||||||
def initialize(formula, options={})
|
def initialize(formula, options={})
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@strict = !!options[:strict]
|
@strict = !!options[:strict]
|
||||||
|
@online = !!options[:online]
|
||||||
@problems = []
|
@problems = []
|
||||||
@text = FormulaText.new(formula.path)
|
@text = FormulaText.new(formula.path)
|
||||||
@specs = %w{stable devel head}.map { |s| formula.send(s) }.compact
|
@specs = %w{stable devel head}.map { |s| formula.send(s) }.compact
|
||||||
@ -230,6 +233,7 @@ class FormulaAuditor
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return unless @online
|
||||||
same_name_tap_formulae = Formula.tap_names.select do |tap_formula_name|
|
same_name_tap_formulae = Formula.tap_names.select do |tap_formula_name|
|
||||||
user_name, _, formula_name = tap_formula_name.split("/", 3)
|
user_name, _, formula_name = tap_formula_name.split("/", 3)
|
||||||
user_name == "homebrew" && formula_name == name
|
user_name == "homebrew" && formula_name == name
|
||||||
@ -423,7 +427,7 @@ class FormulaAuditor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def audit_github_repository
|
def audit_github_repository
|
||||||
return unless @strict
|
return unless @online
|
||||||
|
|
||||||
regex = %r{https?://github.com/([^/]+)/([^/]+)/?.*}
|
regex = %r{https?://github.com/([^/]+)/([^/]+)/?.*}
|
||||||
_, user, repo = *regex.match(formula.stable.url) if formula.stable
|
_, user, repo = *regex.match(formula.stable.url) if formula.stable
|
||||||
|
|||||||
@ -481,7 +481,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
install_passed = steps.last.passed?
|
install_passed = steps.last.passed?
|
||||||
audit_args = [canonical_formula_name]
|
audit_args = [canonical_formula_name]
|
||||||
audit_args << "--strict" if @added_formulae.include? formula_name
|
audit_args << "--strict" << "--online" if @added_formulae.include? formula_name
|
||||||
test "brew", "audit", *audit_args
|
test "brew", "audit", *audit_args
|
||||||
if install_passed
|
if install_passed
|
||||||
if formula.stable? && !ARGV.include?('--no-bottle')
|
if formula.stable? && !ARGV.include?('--no-bottle')
|
||||||
|
|||||||
@ -38,7 +38,7 @@ Note that these flags should only appear after a command.
|
|||||||
|
|
||||||
## COMMANDS
|
## COMMANDS
|
||||||
|
|
||||||
* `audit` [--strict] [<formulae>]:
|
* `audit` [--strict] [--online] [<formulae>]:
|
||||||
Check <formulae> for Homebrew coding style violations. This should be
|
Check <formulae> for Homebrew coding style violations. This should be
|
||||||
run before submitting a new formula.
|
run before submitting a new formula.
|
||||||
|
|
||||||
@ -47,6 +47,9 @@ Note that these flags should only appear after a command.
|
|||||||
If `--strict` is passed, additional checks are run. This should be used
|
If `--strict` is passed, additional checks are run. This should be used
|
||||||
when creating for new formulae.
|
when creating for new formulae.
|
||||||
|
|
||||||
|
If `--online` is passed, additional slower checks that require a network
|
||||||
|
connection are run. This should be used when creating for new formulae.
|
||||||
|
|
||||||
`audit` exits with a non-zero status if any errors are found. This is useful,
|
`audit` exits with a non-zero status if any errors are found. This is useful,
|
||||||
for instance, for implementing pre-commit hooks.
|
for instance, for implementing pre-commit hooks.
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ Perform a substring search of formula names for \fItext\fR\. If \fItext\fR is su
|
|||||||
.SH "COMMANDS"
|
.SH "COMMANDS"
|
||||||
.
|
.
|
||||||
.IP "\(bu" 4
|
.IP "\(bu" 4
|
||||||
\fBaudit\fR [\-\-strict] [\fIformulae\fR]: Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\.
|
\fBaudit\fR [\-\-strict] [\-\-online] [\fIformulae\fR]: Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
If no \fIformulae\fR are provided, all of them are checked\.
|
If no \fIformulae\fR are provided, all of them are checked\.
|
||||||
@ -53,6 +53,9 @@ If no \fIformulae\fR are provided, all of them are checked\.
|
|||||||
If \fB\-\-strict\fR is passed, additional checks are run\. This should be used when creating for new formulae\.
|
If \fB\-\-strict\fR is passed, additional checks are run\. This should be used when creating for new formulae\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
If \fB\-\-online\fR is passed, additional slower checks that require a network connection are run\. This should be used when creating for new formulae\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
\fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\.
|
\fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\.
|
||||||
.
|
.
|
||||||
.IP "\(bu" 4
|
.IP "\(bu" 4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user