Skip to content

Commit

Permalink
Special case Homebrew organization taps
Browse files Browse the repository at this point in the history
We allow homebrew/dupes for instance, rather than Homebrew/dupes. Because nobody likes shifting in the terminal.

In the process of doing this I discovered some case-insensitive filesystem bugs we have avoided before because I had the foresight to mandate lowercase in formula names. GitHub considers Homebrew and homebrew to be different (even though you can't create both). So we had to allow case insensitivity in tap input. I have made it now so the resulting directory however is lowercased, neatly avoiding the issue. And so we also downcase tap arguments when applying them to tap directories or formula.
  • Loading branch information
mxcl committed Mar 18, 2012
1 parent 087408b commit 41b0e85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Library/Homebrew/cmd/tap.rb
Expand Up @@ -14,12 +14,17 @@ def tap
def install_tap user, repo
raise "brew install git" unless system "/usr/bin/which -s git"

tapd = HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}"
# 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}"
raise "Already tapped!" if tapd.directory?
abort unless system "git clone https://github.com/#{user}/homebrew-#{repo} #{tapd}"
abort unless system "git clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}"

files = []
tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) }
tapd.find_formula{ |file| files << tapd.basename.join(file) }
tapped = link_tap_formula(files)
puts "Tapped #{tapped} formula"
end
Expand Down
8 changes: 8 additions & 0 deletions Library/Homebrew/cmd/untap.rb
Expand Up @@ -3,6 +3,14 @@
module Homebrew extend self
def untap
user, repo = tap_args

# 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 = HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}"

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

0 comments on commit 41b0e85

Please sign in to comment.