Update brew tap
to work without 'homebrew-'
#18366
Conversation
Looks great. Will give it a bit for anyone else to chime in and I'll merge shortly if not. |
Thanks and sounds good. Once this is merged, I'll update the |
👍 |
@MikeMcQuaid ping |
Sorry, was on holiday. This is on my todo list; will get to it shortly! |
@MikeMcQuaid No worries. I just wanted to bump it in case it was forgotten. (Hope the holiday was good.) |
Pushed with tweaks. Thanks! |
Sorry, reverted this. |
See #18432. |
@MikeMcQuaid Argh. So two quick questions:
Damn, damn, damn. |
@telemachus Chill, don't worry about it. I didn't see this either because I also had the authentication cached locally. I think doing something with Curl to check the remote first makes sense to me. |
Cool. I won't get right back to this, but I'll play with the |
You can use github api: http://developer.github.com/v3/repos. But that still wouldn't help you discover private repos. |
I think option 1 is going to be a tough sell. Why should we implement, debug and support complicated things for the underwhelming payoff of saving people from typing Option 2 is completely reasonable and something we should implement. |
That appears to return "not found" for private repositories. Many people using taps are using private repos to keep custom stuff private----we cannot assume "not found" means "not tappable". |
Case in point:
|
Separate potential issue I just realized: There's a possibility that a @Sharpie I disagree about the value of this feature. I think it's definitely worth the effort to allow repos without the "homebrew-" prefix in the name. (see: silentbicycle/tangram#1 (comment) for an example) |
What about supporting non github taps ? |
@humdedum that is also desired, but there are unresolved questions about where to place the taps on a user's local filesystem to avoid conflicts. See #11695. |
The simplest solution given we want to support non-github taps and to avoid shadowing or extra calls is I think to just allow using non-homebrew-prefixed taps by specifying the full Git URL. |
(Ok, so my "simplest solution" isn't very simple. Sue me!) |
Or would it be unrecoverable cool factor loss if we require full user/repo and ditch the shortcut ? |
@Sharpie I have a version that checks for repos at the low, low cost of (at worst) two extra It also has the benefit of fixing the bug that @jacknagel mentions in existing versions of |
Currently `brew tap` only works on repos with 'homebrew-' in their name. This version tries to find 'homebrew-repo' and then falls back to try 'repo' if that fails. In the process of fixing #18432, I've made a number of changes: + Followed @englishm's advice and checked for 'homebrew-repo' *first*. + Rather than `begin...rescue` for curl, I've used backticks and a manual check of $? to be more consistent with the rest of the method. + Fixed the error message if the repo is private: the read-only git URL should be in the form git://github.com/#{repouser}/#{repo}.git I think. I've also tweaked the regex in tap_args to allow '-' in repo names. The previous regex required a match on \w. This made it impossible for people to tap repos with names like 'username/why-not'.
Ping @MikeMcQuaid @Sharpie @jacknagel @englishm I think this version covers the bases without too much extra code.
|
abort unless system "git clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}" | ||
|
||
# Work out whether we want to look at 'repo' or 'homebrew-repo' first. | ||
`curl -Ifso /dev/null https://github.com/#{repouser}/homebrew-#{repo}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not printing the output I recommend just using quiet_system
and using the boolean return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I wasn't aware of either quiet_system
or safe_system
. Sorry if this is a dumb question, but is there any place where "extra" internal Homebrew methods like this are documented? If not, it would be great to put on the wiki (I'm willing to help).
if $?.success? | ||
repo = 'homebrew-' + repo | ||
else | ||
`curl -Ifso /dev/null https://github.com/#{repouser}/#{repo}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
Made a few suggestions for changes. Want to let at least another person (probably @Sharpie or @jacknagel) merge it this time just to be safe (more sets of eyes and all that). |
Ok, I now see that this doesn't solve the private repo problem. Private repos will always require authentication (whether cached or explicit), so I'm not sure how best to handle that. One thought: add a flag ( This wouldn't affect existing taps at all (they're already symlinked), but it would require people using I'm also now considering an alternative |
I can make it with full user/repo ( |
@telemachus Does the private repo problem come from this patch or already exist; I'm a bit confused. If it's no worse then that's ok with me. |
@humdedum It's easy to do if we stop special-casing |
@MikeMcQuaid One bug already exists, but this adds a second one.
Having said that, I'm not sure what the best way forward is. I've already started writing an alternative |
With main brew tap I think the least painful solution would probably just be to keep the current format requirement unless a full URL is passed in which case we tap as-is and try and convert that naming into some sensible directory name which, I'll admit, is a fair bit more work. |
Now I'm confused. Remind me, please, what do you mean by "convert that naming into some sensible directory name"? |
For the URL approach we'd need to convert the URL into a directory name suitable for Library/Taps. |
so just basename('.git') equivalent? |
Ah. I guess I would have just defaulted to treating it like |
I think we'd want something that would allow take the who URL into account probably so |
Ok. I'm inclined to close this pull-request and rethink it all. But before I do, can I ask interested parties to weigh in on two questions:
|
I had a burst of energy, and I have a working version of an external command that extends (so to speak) If anyone is interested, I could use testers: https://github.com/telemachus/homebrew-anytap. For the moment, I'm going to close this, since I can't really see any way forward at the moment, but maybe at some later time, we can try to get some of the better tested ideas from |
Currently `brew tap` only works on repos with 'homebrew-' in their name. This version tries the repo name as is and then falls back to try 'homebrew-repo' only if that fails. I've also tweaked the regex in tap_args to allow '-' in repo names. The previous regex required a match on \w. This made it impossible for people to tap repos with names like 'username/why-not'. Closes Homebrew#18366. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This reverts commit d72901f. References Homebrew#18366. Closes Homebrew#18432.
Currently
brew tap
only works on repos with 'homebrew-' in their name.This version tries the repo name as is and then falls back to try
'homebrew-repo' only if that fails.
I've also tweaked the regex in tap_args to allow '-' in repo names. The
previous regex required a match on \w. This made it impossible for people
to tap repos with names like 'username/why-not'.
Ping @MikeMcQuaid (screwed up and opened a new pr again - too tired, sorry)