Git-Repository

 view release on metacpan or  search on metacpan

eg/build-git  view on Meta::CPAN

    my %alias = (
        '1.0.1'   => '1.0.0a',
        '1.0.2'   => '1.0.0b',
    );
    my %seen;
    @versions = grep !$seen{$_}++, map $alias{$_} || $_, @versions;
}

@versions = grep !/rc/, @versions if !$option{rc};

@versions = grep !is_installed($_), @versions if $option{missing};
@versions = grep is_installed($_),  @versions if $option{installed};

@versions = grep cmp_git( $option{since}, $_ ) <= 0, @versions if $option{since};
@versions = grep cmp_git( $_, $option{until} ) <= 0, @versions if $option{until};

@versions = $option{limit} > 0
  ? @versions[ -$option{limit} .. -1 ]       # <limit> most recent
  : @versions[ 0 .. -$option{limit} - 1 ]    # <limit> most ancient
  if $option{limit};


# pick up invalid versions
my @nope = grep !exists $tag_for{$_}, @versions;
die "Can't compile non-existent versions: @nope\n" if @nope;

# just list the selected versions
print map "$_\n", @versions and exit if $option{list};

# test outputs TAP
if ( $option{test} ) {
    require Test::More;
    import Test::More;
    plan( tests => scalar @versions );
    $option{destination} = tempdir( CLEANUP => 1 );
}

# build install select versions
chdir $option{source} or die "Can't chdir to $option{source}: $!";
for my $version (@versions) {

    # skip if that git already exists (and runs)
    if ( is_installed($version) && !$option{force} ) {
        print "*** GIT $version ALREADY INSTALLED ***\n" if !$option{quiet};
        next;
    }
    else {
        print "*** GIT $version ***\n" if !$option{quiet};
        $r->run( checkout => '-f', '-q', $tag_for{$version} );
        $r->run( clean => '-xqdf' );

        # Fix various issues in the Git sources

        # Fix GIT-VERSION-GEN to use `git describe` instead of `git-describe`
        if (
            cmp_git( $version, '1.3.3' ) <= 0
            && cmp_git( '1.1.0', $version ) <= 0
            && do { no warnings; `git-describe`; $? != 0 }
          )
        {
            local ( $^I, @ARGV ) = ( '', 'GIT-VERSION-GEN' );
            s/git-describe/git describe/, print while <>;
        }

        # fix GIT_VERSION in the Makefile
        if ( cmp_git( $version, '1.0.9' ) == 0 ) {
            local ( $^I, @ARGV ) = ( '', 'Makefile' );
            s/^GIT_VERSION = .*/GIT_VERSION = $version/, print while <>;
        }

        # add missing #include <sys/resource.h>
        elsif (   cmp_git( $version, '1.7.5.rc0' ) <= 0
            && cmp_git( '1.7.4.2', $version ) <= 0 )
        {
            $r->run( 'cherry-pick', '-n',
                'ebae9ff95de2d0b36b061c7db833df4f7e01a41d' );

            # force the expected version number
            my $version_file = File::Spec->catfile( $r->work_tree, 'version' );
            open my $fh, '>', $version_file
              or die "Can't open $version_file: $!";
            print $fh "$version\n";
        }

        # settings
        my $prefix = File::Spec->catdir( $option{destination}, $version );
        my @make = ( make => "prefix=$prefix" );

        # clean up environment (possibly set by local::lib)
        local $ENV{PERL_MB_OPT};
        local $ENV{PERL_MM_OPT};
        remove_tree( $prefix ) if -e $prefix;

        # build
        run_cmd( @make => '-j3' );

        # install
        run_cmd( @make => 'install' );
        run_cmd( @make => 'install-doc' ) if $option{docs};

        # test the installation and remove all
        if ( $option{test} ) {
            ok( is_installed($version), "$version installed successfully" );
            remove_tree( $prefix );
        }
    }
}

sub run_cmd {
    print "* @_\n" if !$option{quiet};
    System::Command->loop_on( command => \@_, %run_opt ) or die "FAIL: @_\n";
}

sub is_installed {
    my ($version) = @_;
    my $git =
      File::Spec->catfile( $option{destination}, $version, 'bin', 'git' );
    return eval { Git::Repository->version_eq( $version, { git => $git } ) };
}

__END__

=pod

=head1 NAME

build-git - Build and install any Git



( run in 1.154 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )