Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 36 lines (26 sloc) 769 Bytes
#!/usr/bin/env perl
use strict;
use warnings;
use File::Path;
use Getopt::Long;
use GitGraph;
my %conf = ( repository => 'cayley' );
GetOptions( \%conf, 'repository=s' )
or die "Usage: $0 [ --repository <repository> ]";
my $depth = shift || 0;
init( $conf{repository} ) if !-e $conf{repository};
my $r = Git::Repository->new( work_tree => $conf{repository} );
sub cayley {
my ( $branch, $n, $root ) = @_;
# create node
return node($r, $branch) if !$n;
# branches
my @nodes = (
cayley( $branch, $n - 1 ),
cayley( $branch, $n - 1 ),
cayley( $branch, $n - 1 )
);
push @nodes, cayley( $branch, $n - 1 ) if $root; # first item
return node( $r, $branch, @nodes);
}
cayley( "cayley-$depth", $depth, 1 );