Merge pull request #16865 from cho-m/cask-audit-@
cask/audit: allow @ for versioned casks
This commit is contained in:
commit
a30f6c48f2
@ -407,17 +407,20 @@ module Cask
|
|||||||
add_error "cask token contains non-ascii characters" unless cask.token.ascii_only?
|
add_error "cask token contains non-ascii characters" unless cask.token.ascii_only?
|
||||||
add_error "cask token + should be replaced by -plus-" if cask.token.include? "+"
|
add_error "cask token + should be replaced by -plus-" if cask.token.include? "+"
|
||||||
add_error "cask token whitespace should be replaced by hyphens" if cask.token.include? " "
|
add_error "cask token whitespace should be replaced by hyphens" if cask.token.include? " "
|
||||||
add_error "cask token @ should be replaced by -at-" if cask.token.include? "@"
|
|
||||||
add_error "cask token underscores should be replaced by hyphens" if cask.token.include? "_"
|
add_error "cask token underscores should be replaced by hyphens" if cask.token.include? "_"
|
||||||
add_error "cask token should not contain double hyphens" if cask.token.include? "--"
|
add_error "cask token should not contain double hyphens" if cask.token.include? "--"
|
||||||
|
|
||||||
if cask.token.match?(/[^a-z0-9-]/)
|
if cask.token.match?(/[^@a-z0-9-]/)
|
||||||
add_error "cask token should only contain lowercase alphanumeric characters and hyphens"
|
add_error "cask token should only contain lowercase alphanumeric characters, hyphens and @"
|
||||||
end
|
end
|
||||||
|
|
||||||
return if !cask.token.start_with?("-") && !cask.token.end_with?("-")
|
if cask.token.start_with?("-", "@") || cask.token.end_with?("-", "@")
|
||||||
|
add_error "cask token should not have leading or trailing hyphens and/or @"
|
||||||
|
end
|
||||||
|
|
||||||
add_error "cask token should not have leading or trailing hyphens"
|
add_error "cask token @ unrelated to versioning should be replaced by -at-" if cask.token.count("@") > 1
|
||||||
|
add_error "cask token should not contain a hyphen followed by @" if cask.token.include? "-@"
|
||||||
|
add_error "cask token should not contain @ followed by a hyphen" if cask.token.include? "@-"
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
|
@ -220,11 +220,43 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when cask token has @" do
|
context "when cask token is @-versioned with number" do
|
||||||
let(:cask_token) { "app@stuff" }
|
let(:cask_token) { "app@10" }
|
||||||
|
|
||||||
|
it "does not fail" do
|
||||||
|
expect(run).to pass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when cask token is @-versioned with word" do
|
||||||
|
let(:cask_token) { "app@beta" }
|
||||||
|
|
||||||
|
it "does not fail" do
|
||||||
|
expect(run).to pass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when cask token has multiple @" do
|
||||||
|
let(:cask_token) { "app@stuff@beta" }
|
||||||
|
|
||||||
it "fails" do
|
it "fails" do
|
||||||
expect(run).to error_with(/@ should be replaced by -at-/)
|
expect(run).to error_with(/@ unrelated to versioning should be replaced by -at-/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when cask token has a hyphen followed by @" do
|
||||||
|
let(:cask_token) { "app-@beta" }
|
||||||
|
|
||||||
|
it "fails" do
|
||||||
|
expect(run).to error_with(/should not contain a hyphen followed by @/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when cask token has @ followed by a hyphen" do
|
||||||
|
let(:cask_token) { "app@-beta" }
|
||||||
|
|
||||||
|
it "fails" do
|
||||||
|
expect(run).to error_with(/should not contain @ followed by a hyphen/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -248,7 +280,7 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
let(:cask_token) { "app(stuff)" }
|
let(:cask_token) { "app(stuff)" }
|
||||||
|
|
||||||
it "fails" do
|
it "fails" do
|
||||||
expect(run).to error_with(/alphanumeric characters and hyphens/)
|
expect(run).to error_with(/alphanumeric characters, hyphens and @/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user