Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created January 20, 2019 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlbright/d15f4b5bc00ad92face38e9091dbd58a to your computer and use it in GitHub Desktop.
Save mlbright/d15f4b5bc00ad92face38e9091dbd58a to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw{ say };
use Getopt::Long;
my $options = {};
GetOptions( $options, "--directory=s", "--start=s", "--finish=s" );
my $dir = $options->{directory} || undef;
# git --no-pager log --all --name-only --format="%h => [%ct] %ce" | tee /tmp/maya-commits.txt
my %commits;
my $commit;
my $timestamp;
while ( my $line = <> ) {
chomp $line;
if ( $line =~ /^([0-9a-f]{5,40}) => \[(\d+)\]/ ) {
$commit = $1;
$timestamp = $2;
push @{ $commits{$commit} }, [];
}
else {
push @{ $commits{$commit} }, $line;
}
}
my %matches;
for my $commit ( keys %commits ) {
$matches{$commit} = 0;
for my $line ( @{ $commits{$commit} } ) {
if ( $line =~ /$dir/ ) {
$matches{$commit} = 1;
}
}
}
for my $commit ( keys %matches ) {
if ( $matches{$commit} ) {
say $commit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment