This repository has been archived by the owner. It is now read-only.

`brew versions` doesn't work for tapped formulae #12356

Closed
mistydemeo opened this Issue May 21, 2012 · 6 comments

Comments

Projects
None yet
4 participants
Contributor

mistydemeo commented May 21, 2012

brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running git, and as such fails to report previous versions for any formulae from a tapped repository.

Contributor

jacknagel commented May 22, 2012

Formula has a tap method, so it shouldn't be difficult to make it work:

  • add a private method that constructs the correct repository path;
  • replace uses of HOMEBREW_REPOSITORY with calls to that method;
  • make the use of 'Library/Formula' prefix in git invocations conditional*;
  • teach pretty_relative_path to respect taps

* This may be a little tricky; depending how the "recursively search taps" debate comes out, there might not be a reliable directory structure for taps.

Contributor

jacknagel commented May 22, 2012

Separately, what do you think of caching versions information?

It can be pretty I/O intensive for formulae that are touched by a large number of commits. We have the JSON machinery at our disposal, so it would be pretty trivial to record a mapping of commits to versions on a per-formula basis and just stick it in HOMEBREW_CACHE/Versions.

Cache invalidation could be done by comparing the git HEAD at write-time and read-time, and we could use the write-time HEAD to limit how far back into the history we walk the next time around.

Owner

MikeMcQuaid commented May 22, 2012

So it would just cache for the e.g. second time you run brew versions? Seems reasonable to me.

Contributor

jacknagel commented Aug 18, 2012

Here's my quick hack of a brew versions cache:

https://github.com/jacknagel/homebrew/compare/versions

It gives a noticeable speedup, but it's unpolished, and it's confusing so I'm not sure it's worth the added complexity, especially since this command is probably not used all that often. Some bits would need to be factored out into methods to make it readable. Also it may interfere with making brew versions usable with taps.

But I thought I'd throw it up there rather than just delete the branch. If anyone wants to clean it up and submit it, feel free to steal the code. brew cleanup probably needs to be taught to empty this cache as well.

@jiangxin jiangxin added a commit to jiangxin/homebrew that referenced this issue Apr 9, 2013

@jiangxin jiangxin versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.

Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.

Closes #12356.

Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
624ff60
Contributor

jiangxin commented Apr 9, 2013

When I write a brew tap formula, I found the same issue: brew versions not work for tapped formulae.
So I write a fix for this. See pull request: #19069.

Contributor

jacknagel commented Apr 9, 2013

Closing in favor of #19069

@jacknagel jacknagel closed this Apr 9, 2013

@jacknagel jacknagel added a commit that referenced this issue Apr 12, 2013

@jiangxin @jacknagel jiangxin + jacknagel versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.

Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.

Closes #12356.
Closes #19069.

Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
885292e

@nesv nesv added a commit to nesv/homebrew that referenced this issue Apr 12, 2013

@jiangxin @nesv jiangxin + nesv versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.

Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.

Closes #12356.
Closes #19069.

Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
c5c0939

@ekarulf ekarulf added a commit to ekarulf/homebrew that referenced this issue Apr 15, 2013

@jiangxin @ekarulf jiangxin + ekarulf versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.

Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.

Closes #12356.
Closes #19069.

Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
b4c602e

@dshean dshean added a commit to dshean/homebrew that referenced this issue Sep 24, 2013

@jiangxin @dshean jiangxin + dshean versions: work for tapped formulae
brew versions is hardcoded to cd to HOMEBREW_REPOSITORY before running
git, and as such fails to report previous versions for any formulae
from a tapped repository.

Add two new private methods repository and entry_name to replace the
hardcoded HOMEBREW_REPOSITORY and formula path, and brew versions
work for both builtin and tapped formulae.

Closes #12356.
Closes #19069.

Reported-by: Misty De Meo <mistydemeo@gmail.com>
Suggested-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
38dc7c0

@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.