PrePAN

Sign in to PrePAN

Git::Features What features shipped with which version of Git

Author
book@github
Date
URL
Status
In Review
Good

Synopsis

What commands/features are available in a given version of Git?

    # add commit init ...
    @features = Git::Features->commands_in( '1.5.0' );

    # add commit init/outside_of_dir ...
    @features = Git::Features->features_in( '1.6.5' );

When did a specific feature become available?

    # 1.5.0.rc1
    $version = Git::Features->minimum_version_with( 'init' );

    # 1.6.5
    $version = Git::Features->minimum_version_with( 'init/outside_of_dir' );

    # 1.0.0
    $version = Git::Features->minimum_version_with( 'tar-tree' );

When did a specific command/feature disappear?

    # 1.8.5.6
    $version = Git::Features->maximum_version_with( 'tar-tree' );

Even getting the version number is not a simple `git version` with older git (luckily `git --version` always works):

    # 1.3.0.rc1
    $version = Git::Features->minimum_version_with( 'version' );

Description

The idea of this module is to provide something similar to Module::CoreList, but for Git features.

Some git commands have been discontinued, some have appeared at a certain version. Some git commands have acquired specific features over time (for example init and init-db).

This module is meant to help people writing git script (using any of the existing Perl git wrappers, or even git itself) figure out which is the minimum version of Git they need according to the commands and features they depend on.

Command names are the usual git command names. Features will probably be more "ad-hoc", but always prefixed with the command name, separated by a slash. The only feature that I have in mind for now is init/outside_of_dir (see the above link).

My plan is to go as far as git version 1.0, possibly a few releases before.

I'm not entirely sure of the interface yet, and if I should support things like changes_between or removed_from like Module::CoreList does.

Comments

Excellent!

It would be also helpful to have a second API (but in fact just another independant module that would use this one) that would allow to check multiple things against a given version:
```
my $git_check = Git::Has->new(`git --version`);
if ($git_check->has_command('tar-tree') {
...
}
if ($git_check->has_command('symbolic-ref' => '--short') {
...
}
```
I was thinking about this again, and thought that maybe that second API could be part of a plugin:

use Git::Repository qw( Features ); # loads Git::Repository::Plugin::Features
Git::Repository->has_feature( ... ); # or has_command

Please sign up to post a review.