Merge pull request #16778 from reitermarkus/tap-sig-4
Simplify `Tap#custom_remote?`.
This commit is contained in:
commit
8d4e841965
@ -524,10 +524,11 @@ class Tap
|
|||||||
end
|
end
|
||||||
|
|
||||||
# True if the {#remote} of {Tap} is customized.
|
# True if the {#remote} of {Tap} is customized.
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
def custom_remote?
|
def custom_remote?
|
||||||
return true unless remote
|
return true unless (remote = self.remote)
|
||||||
|
|
||||||
remote.casecmp(default_remote).nonzero?
|
!remote.casecmp(default_remote).zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Path to the directory of all {Formula} files for this {Tap}.
|
# Path to the directory of all {Formula} files for this {Tap}.
|
||||||
|
@ -258,6 +258,37 @@ RSpec.describe Tap do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#custom_remote?" do
|
||||||
|
subject(:tap) { described_class.new("Homebrew", "services") }
|
||||||
|
|
||||||
|
let(:remote) { nil }
|
||||||
|
|
||||||
|
before do
|
||||||
|
tap.path.mkpath
|
||||||
|
system "git", "-C", tap.path, "init"
|
||||||
|
system "git", "-C", tap.path, "remote", "add", "origin", remote if remote
|
||||||
|
end
|
||||||
|
|
||||||
|
context "if no remote is available" do
|
||||||
|
it "returns true" do
|
||||||
|
expect(tap.remote).to be_nil
|
||||||
|
expect(tap.custom_remote?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when using the default remote" do
|
||||||
|
let(:remote) { "https://github.com/Homebrew/homebrew-services" }
|
||||||
|
|
||||||
|
its(:custom_remote?) { is_expected.to be false }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when using a non-default remote" do
|
||||||
|
let(:remote) { "git@github.com:Homebrew/homebrew-services" }
|
||||||
|
|
||||||
|
its(:custom_remote?) { is_expected.to be true }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
specify "Git variant" do
|
specify "Git variant" do
|
||||||
touch path/"README"
|
touch path/"README"
|
||||||
setup_git_repo
|
setup_git_repo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user