Fix bump-formula-pr for taps with ssh remote url.

This commit is contained in:
Zach Auten 2021-04-22 22:02:09 -04:00
parent afbe0e8086
commit 95c8f445fa
2 changed files with 17 additions and 1 deletions

View File

@ -146,6 +146,7 @@ class Tap
return unless remote return unless remote
@remote_repo ||= remote.delete_prefix("https://github.com/") @remote_repo ||= remote.delete_prefix("https://github.com/")
.delete_prefix("git@github.com:")
.delete_suffix(".git") .delete_suffix(".git")
end end

View File

@ -206,7 +206,7 @@ describe Tap do
end end
describe "#remote_repo" do describe "#remote_repo" do
it "returns the remote repository" do it "returns the remote https repository" do
setup_git_repo setup_git_repo
expect(homebrew_foo_tap.remote_repo).to eq("Homebrew/homebrew-foo") expect(homebrew_foo_tap.remote_repo).to eq("Homebrew/homebrew-foo")
@ -221,6 +221,21 @@ describe Tap do
expect(services_tap.remote_repo).to eq("Homebrew/homebrew-bar") expect(services_tap.remote_repo).to eq("Homebrew/homebrew-bar")
end end
it "returns the remote ssh repository" do
setup_git_repo
expect(homebrew_foo_tap.remote_repo).to eq("Homebrew/homebrew-foo")
expect { described_class.new("Homebrew", "bar").remote_repo }.to raise_error(TapUnavailableError)
services_tap = described_class.new("Homebrew", "services")
services_tap.path.mkpath
services_tap.path.cd do
system "git", "init"
system "git", "remote", "add", "origin", "git@github.com:Homebrew/homebrew-bar"
end
expect(services_tap.remote_repo).to eq("Homebrew/homebrew-bar")
end
it "returns nil if the Tap is not a Git repository" do it "returns nil if the Tap is not a Git repository" do
expect(homebrew_foo_tap.remote_repo).to be nil expect(homebrew_foo_tap.remote_repo).to be nil
end end