Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

tap by specifying clone_url directly #12383

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions Library/Homebrew/cmd/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ def tap
if ARGV.empty?
tapd = HOMEBREW_LIBRARY/"Taps"
tapd.children.each do |tap|
puts tap.basename.sub('-', '/') if (tap/'.git').directory?
next unless (tap/'.git').directory?
puts tap.basename.to_s =~ /^direct_/ ? tap.basename.sub(/^direct_/,'') : tap.basename.sub('-','/')
end if tapd.directory?
else
install_tap(*tap_args)
end
end

def install_tap user, repo
def install_tap clone_url, tapd_name
raise "brew install git" unless which 'git'

# we special case homebrew so users don't have to shift in a terminal
repouser = if user == "homebrew" then "Homebrew" else user end
user = "homebrew" if user == "Homebrew"

# we downcase to avoid case-insensitive filesystem issues
tapd = HOMEBREW_LIBRARY/"Taps/#{user.downcase}-#{repo.downcase}"
tapd = HOMEBREW_LIBRARY/"Taps/#{tapd_name.downcase}"
raise "Already tapped!" if tapd.directory?
abort unless system "git clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}"
abort unless system "git clone #{clone_url} #{tapd}"

files = []
tapd.find_formula{ |file| files << tapd.basename.join(file) }
Expand Down Expand Up @@ -60,10 +57,24 @@ def link_tap_formula formulae

private

def tap_args
ARGV.first =~ %r{^(\S+)/(homebrew-)?(\w+)$}
raise "Invalid usage" unless $1 and $3
[$1, $3]
def tap_args return_nil = false
case ARGV.first
when %r{^(https?|git)://\S+/(\S+?)(\.git)?$}
[ARGV.first, "direct_#{File.basename($2)}"]
when %r{^\S+@\S+:(\S+?)(\.git)?$}
[ARGV.first, "direct_#{File.basename($1)}"]
when %r{^(\S+)/(homebrew-)?(\w+)$}
user, repo = $1, $3

# we special case homebrew so users don't have to shift in a terminal
repouser = if user == "homebrew" then "Homebrew" else user end
user = "homebrew" if user == "Homebrew"

["https://github.com/#{repouser}/homebrew-#{repo}", "#{user}-#{repo}"]
else
return nil if return_nil
raise "Invalid usage"
end
end

end
Expand Down
11 changes: 6 additions & 5 deletions Library/Homebrew/cmd/untap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

module Homebrew extend self
def untap
user, repo = tap_args
clone_url, tapd_name = tap_args(true)

tapd_name = "direct_#{ARGV.first}" unless tapd_name

# we consistently downcase in tap to ensure we are not bitten by case-insensive
# filesystem issues. Which is the default on mac. The problem being the
# filesystem cares, but our regexps don't. So unless we resolve *every* path
# we will get bitten.
user.downcase!
repo.downcase!
tapd_name.downcase!

tapd = HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}"
tapd = HOMEBREW_LIBRARY/"Taps/#{tapd_name}"

raise "No such tap!" unless tapd.directory?

files = []
tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) }
tapd.find_formula{ |file| files << Pathname.new(tapd_name).join(file) }
untapped = unlink_tap_formula(files)
rm_rf tapd
puts "Untapped #{untapped} formula"
Expand Down