An alternative `brew tap` external command for Homebrew
Ruby
Switch branches/tags
Nothing to show
Latest commit c518671 Jun 11, 2015 @telemachus We are closed
Permalink
Failed to load latest commit information.
Formula Fix #8 Jun 2, 2015
README.md We are closed Jun 11, 2015
brew-any-tap.rb Fix #8 Jun 2, 2015
brew-any-untap.rb Fix #8 Jun 2, 2015

README.md

any-tap.rb: brew tap for everything!

NOTICE (2015-06-11)

Good news

Homebrew recently merged brew any-tap into brew tap. That means that you no longer need to install or use this external command. I'm not deleting the code in any hurry, but you should uninstall, especially given the bad news below.

Bad news

After the merge, brew tap changed its internals somewhat (for the better), and as a result brew any-tap and brew any-untap are broken. You should uninstall and instead use brew tap and brew untap.

tl;dr brew anytap is out of business because it's no longer necessary. Everything below is only of historical interest.

Introduction

brew any-tap is an external command that extends brew's built-in tap command. brew tap is a convenient way to add personal or non-standard repositories of formulas to Homebrew, but it only works on public GitHub repositories that follow specific naming conventions. By contrast, brew any-tap works with any git repository, public and private, on GitHub or anywhere else.

This command scratches my itch. I wanted a souped-up version of brew tap. I have freely borrowed (ahem, stolen) code from the existing brew tap command. I thank all the people who worked on that.

Installation

  • The easiest thing is (ironically?) to use brew tap:

      brew tap telemachus/anytap
      brew install brew-any-tap
    

    That will install brew any-tap and brew any-untap. See below for usage notes on both.

  • If you prefer, however, you can simply clone this repository and then copy brew-any-tap.rb and brew-any-untap.rb anywhere in your $PATH.

    If you do that, brew will automatically be able to pick up the commands and do the right thing with them.

Usage

  • brew any-tap
    • brew any-tap: List currently installed taps
    • brew any-tap -h|-?|--help: Get usage
    • brew any-tap -r|--repair: Migrate to Homebrew's new, no-symlink taps
    • brew any-tap user name URL: Clone repo at URL as 'user/{homebrew-}name' The prefix 'homebrew-' will be added if not given in order to conform with what other brew commands expect.
  • brew any-untap
    • brew any-untap: List currently installed taps
    • brew any-untap -h|-?|--help: Get usage
    • brew any-untap name1 [name2 name3 ...]: Untap one or more taps

Why brew any-tap?

The key difference between brew tap and brew any-tap is that brew any-tap will attempt to tap any URL that you give it. You can tap private repos, repos not on GitHub, repos on disc rather than online, and repos that don't follow the naming conventions required by brew tap.

The price you pay is that you must be more explicit because brew any-tap and brew any-untap don't make any assumptions. To tap a new repository using brew any-tap requires three arguments. The first two are combined to create the directory structure that brew expects (more on this below), and the last is the URL of repo that you want to clone. brew any-tap will combine the first two arguments and check whether a tap of the same name already exists. If it does, the tap aborts. Otherwise, brew any-tap combines the arguments to run the following command:

    git clone --depth 1 arg3 HOMEBREW_LIBRARY/Taps/arg1/{homebrew-}arg2

To make this a bit more concrete, here's a call and what it would do:

    brew any-tap telemachus myjunk https://telemachus@bitbucket.org/telemachus/brew.git
    # Assuming it doesn't yet exist
    git clone --depth 1 https://telemachus@bitbucket.org/telemachus/brew.git HOMEBREW_LIBRARY/Taps/telemachus/homebrew-myjunk

The prefix 'homebrew-' is added to the second argument, if it's not already present, because other brew commands—in particular brew install—assume that all taps have 'homebrew-' in their name. In order to work smoothly with brew as a whole, brew any-tap will add 'homebrew-' to arg2 as needed.

Historical notes

  1. When brew tap was first created, all taps were added directly below the Taps directory, but after a recent change, they are now added to subdirectories, according to the username of the repo owner on GitHub. That is, all new taps exist at Taps/username/homebrew-reponame. As of version 0.0.9, brew any-tap uses this same structure in order to be fully compatible with the rest of brew.
  2. Once upon a time brew tap used symlinks to find formulas from tapped repos. However, they no longer do. When symlinks were used, the flag --repair would trigger a check and fix of these symlinks. However, the flag now triggers a migration to the current, no-symlink style of tap. As of 1.0.0, brew any-tap works in the same way. I plan to remove the --repair command after a suitable waiting period since it will eventually be pointless.

Contributors

Contributing

Fork, edit and pass me a pull request. Nothing more formal than that.