diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 05861011cb..fad32e455e 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -146,6 +146,7 @@ class Tap return unless remote @remote_repo ||= remote.delete_prefix("https://github.com/") + .delete_prefix("git@github.com:") .delete_suffix(".git") end diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb index dee6405fc9..afb66cbb4c 100644 --- a/Library/Homebrew/test/tap_spec.rb +++ b/Library/Homebrew/test/tap_spec.rb @@ -206,7 +206,7 @@ describe Tap do end describe "#remote_repo" do - it "returns the remote repository" do + it "returns the remote https repository" do setup_git_repo 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") 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 expect(homebrew_foo_tap.remote_repo).to be nil end