#!/usr/bin/env perl use 5.016; use warnings; use autodie; use File::Basename qw(dirname); use IPC::Open2; use Pod::Usage; if (@ARGV < 1) { pod2usage('Missing arguments.'); } elsif (grep { /^--?h(elp)?$/ } @ARGV) { pod2usage(-verbose => 2); } my $dir = dirname($0) . '/lib'; my ($repo, $algorithm, @args) = @ARGV; $algorithm = ucfirst(lc($algorithm // 'default')); my $algorithm_file = "$dir/Graph/Man/Algorithm/$algorithm.pm"; if (!-e $algorithm_file) { die "No such algorithm found at '$algorithm_file'\n"; } # First slurp all the commits from parseman. # We need them all in memory because they are required both at the start of # graphman and at the end of assocman. This uses a lot of memory, but it's # significantly faster than running parseman twice. open my $parseman, '-|', "$dir/parseman", $repo; my @commits = <$parseman>; close $parseman; # Then run graphman and feed all the commits to it. open2 my $graphman, my $to_graphman, "$dir/graphman", $algorithm, @args; print {$to_graphman} @commits; close $to_graphman; # Run assocman and feed the results from the graph to it. open my $to_assocman, '|-', "$dir/assocman"; print {$to_assocman} $_ while <$graphman>; close $graphman; # Finally, feed all the commits and associate them with the identities. The # end result lands on stdout. print {$to_assocman} @commits; close $to_assocman; __END__ =head1 NAME idman - identify unique contributors of a git repository =head1 SYNOPSIS idman GIT_REPO_FOLDER [ALGORITHM ARGS...] =cut