App-Git-Perl
view release on metacpan or search on metacpan
script/git-perl view on Meta::CPAN
}
if ( $command eq "log" ) {
my $module = shift;
exit if ( not $module );
# Call gitlog for $module, and add additional parameter if asked by user (e.g. 'remove')
gitlog($module,shift);
exit;
}
if ( $command eq "local" ) {
my ($subdir, $subcommand) = (shift,shift);
$subdir =~ s#/$## if ( $subdir ); # remove trailing '/' if provided as $subdir
if ( $subdir and not -d "$gitdirs/$subdir" ) {
my $newsubdir = clone( $subdir ); # it suppose the '$subdir' is actually '$modulename'
$subdir = $newsubdir if ( $newsubdir ); # if cloned, use it
}
if ( $subdir and $subcommand ) {
if ( $subcommand eq "remove" ) {
remove( $subdir );
exit;
}
if ( $subcommand eq "log" ) {
gitlog( $subdir );
exit;
}
}
my @local = qx{ cd "${gitdirs}"; ls -1 */dist.ini */Makefile.PL 2>/dev/null | cut -d"/" -f1 | sort | uniq };
chomp( @local );
foreach my $local (@local) {
# If user provided subdir, return data only for that module
if ( $subdir ) {
next if ( $local !~ /$subdir/ );
}
my $modulefile = "";
my $module = "";
my $VERSION = "";
# Makefile.PL
$modulefile = qx{ cd "${gitdirs}"; grep VERSION_FROM "$local/Makefile.PL" 2>/dev/null | grep "=>" | cut -d"=" -f2 | cut -d\\' -f2 | cut -d\\" -f2 | sed -e "s#^#$local/#" };
chomp( $modulefile );
if ( not $modulefile ) {
$modulefile = qx{ cd "${gitdirs}"; grep "all_from" "$local/Makefile.PL" 2>/dev/null | cut -d\\' -f2 | cut -d\\" -f2 | sed -e "s#^#$local/#" };
chomp( $modulefile );
}
if ( not $modulefile ) {
$modulefile = qx{ cd "${gitdirs}"; find "$local/lib" -iname "*.pm" 2>/dev/null | xargs grep -H "package " | sed -e "s/.pm:.*/.pm/" | head -n 1 };
chomp( $modulefile );
}
if ( $modulefile ) {
$module = qx{ cd "${gitdirs}"; cat "$modulefile" | grep "^\\s*package " | sed -e "s/package //" | cut -d";" -f1 | head -n 1 };
chomp( $module );
if ( not $module ) {
$module = $modulefile;
}
$VERSION = qx{ cd "${gitdirs}"; cat "$modulefile" | grep VERSION | grep "[0-9]" | cut -d\\' -f2 | cut -d\\" -f2 | head -n 1 };
chomp( $VERSION );
} else {
# This is just guessing. It returns our...VERSION from first found file.
$module = qx{ cd "${gitdirs}"; cd "$local/" ; grep -rsn VERSION * | grep our | cut -d":" -f1 };
chomp( $module );
$VERSION = qx{ cd "${gitdirs}"; cd "$local/" ; grep -rsn VERSION * | grep our | cut -d\\' -f2 | cut -d\\" -f2 | head -n 1 };
chomp( $VERSION );
}
# $module/$VERSION is just provisioning data, not really used anywhere
print "$local $module $VERSION\n";
}
exit;
}
if ( $command eq "config" ) {
my ($name, $value) = (shift,shift);
my $output = config($name,$value);
print "$output\n" if ($output);
exit;
}
print "ERROR: I do now know what you want? See usage:\n";
usage();
}
main(@ARGV);
__END__ # Documentation
=head1 NAME
git-perl ... - work easily with Perl CPAN modules repositories
=head1 USAGE
git perl recent = shows recent list of changes from https://metacpan.org/recent
git perl log BAYASHI/Object-Container-0.16 = git clone repository and show latest changes
git perl log BAYASHI/Object-Container-0.16 remove = remove cloned repository
git perl log Log::Any = git clone repository and show latest changes
git perl log Log::Any remove = remove cloned repository
git perl clone BAYASHI/Object-Container-0.16 = git clone repository
git perl clone BAYASHI/Object-Container-0.16 remove = remove cloned repository
git perl clone Log::Any = git clone repository
git perl clone Log::Any remove = remove cloned repository
git perl local = list cloned repositories
git perl local object-container-perl = list cloned repository 'object-container-perl'
git perl local object-container-perl log = show latest changes in repository
git perl local object-container-perl remove = remove local repository stored in 'object-container-perl'
git perl local Log::Any = git clone repository ( get remote repository locally )
git perl local Log::Any remove = remove cloned repository
git perl config = show current config ( from ~/.config/git-perl.conf )
git perl config dir = show value of 'dir' from config
git perl config dir ~/git/perl = set value of 'dir' to '~/git/perl'
git perl config --unset dir = remove variable 'dir' from config file
=head1 SYNOPSIS
$ git perl config dir ~/git/perl
$ git perl recent
( run in 2.124 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )