14 Commits

Author SHA1 Message Date
Jack Nagel
1a3a1249bf Warn the user of required arguments
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-02-04 00:27:05 -06:00
Jack Nagel
8809c85cc3 versions: ignore NameError and ArgumentError
Fixes Homebrew/homebrew#9856.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-29 16:00:27 -06:00
Jack Nagel
8944cc6b66 versions: fix up error handling
Now we handle some things more explicitly and in the process get rid of
the blanket rescue on the mktemp block, which is something of an
antipattern.

By unloading the class *after* determining the version, we avoid the
case where the class had previously been unloaded but Formula.factory
failed, and trying to unload the nonexistent class results in a
NameError. Doing it this way, we avoid having to rescue NameError and
thereby avoid hiding other cases where it may occur.

We also rescue TypeError which gets us past a few more bad formula in
the history in some instances.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-27 03:40:24 -06:00
Jack Nagel
d10f2afbac versions: silence 'aka' warning and syntax errors
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-26 23:02:18 -06:00
Dylan Smith
66fbb607fd versions: don't print 'nil' when stdout is not a tty
Closes Homebrew/homebrew#8960.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-24 12:21:08 -06:00
Jack Nagel
e9a0f24ccb versions: use the actual class name when unloading
And document a bit more why this hack is present.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-12 01:16:02 -06:00
Jack Nagel
5bfd8faf90 versions: unload old class before obtaining version
This is silly, but I am no Rubyist and I don't have time to
figure out why Formula.factory(foo).url works as expected but
Formula.factory(foo).version does not.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-06 22:07:45 -06:00
Jack Nagel
f3f04e595d versions: enable '--compact' output
This will be useful for shell tab completion when something like `brew
install <formula> --version <version>` is implemented.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-06 14:51:15 -06:00
Jack Nagel
016a508c7a versions: determine version from a Formula instance
Rather than regex the output of `git show <rev>:<path>`, we write the
output of `git cat-file blog <rev>:<path>` to a temporary file, and then
operate on it just as we would a normal formula.

I haven't observed any speed difference. `git cat-file blob` is faster
than `git show`, but the "slow part" is still the git-rev-list
invocation. But really it's pretty fast overall.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-01-06 14:51:15 -06:00
Max Howell
9cdfd2797f Fix nil handling in brew versions
Fixes Homebrew/homebrew#7392.
2011-09-05 09:44:53 +01:00
Max Howell
48501e8e1f Prettier brew versions output 2011-08-02 14:45:37 +01:00
Max Howell
616b52e627 Oops, show proper git checkout command 2011-08-02 12:58:16 +01:00
Max Howell
18a54259e9 Improvements to brew versions
The output happens as it is determined, rather than all at once, which is preferable for CLI commands. This meant I had to hard-code the left-justification.

The pre-amble warning is removed. Instead the command outputs the git checkout command for each she that you can type to get that old formula.

I decided that reseting the one file will work 99% of the time and that it is too risky to reset the whole repo, this will roll-back bug fixes. Instead we should add functionality to compat/ in order to support old formula as required. Sometimes deps may have to be rolled-back too, but the user will have to figure this out on an ad-hoc basis. We are assuming a failure sophisticated user anyway, one who would like to get old versions of stuff.

I moved most of the functions into Formula since IMO this makes more conceptual sense.

I made the she get abbreviated by git (using --abbrev-commit) itself so it as short as can be.
2011-08-02 12:34:33 +01:00
Sebastian Staudt
6726fe090f Added new command "versions" 2011-08-02 10:35:30 +01:00