Skip to content

Instantly share code, notes, and snippets.

@TrishGillett
Last active May 28, 2016 01:00
Show Gist options
  • Save TrishGillett/5658547bb49319d3a2586e340c670d61 to your computer and use it in GitHub Desktop.
Save TrishGillett/5658547bb49319d3a2586e340c670d61 to your computer and use it in GitHub Desktop.
Perl script to list matplotlib examples ordered by last commit
#!/usr/bin/perl
# I don't claim credit for because I haven't written Perl before and just Frankensteined
# it together from these three sites:
# http://stackoverflow.com/a/17727887
# http://www.perlmonks.org/?node_id=97574
# http://perl.about.com/od/filesystem/qt/perl_file_exist.htm
# Note that the script should be placed inside the examples folder of the matplotlib repo.
# Ask git for a list of access times and files
my @logbook = `git whatchanged --pretty=%ai . `;
my %seen;
my $timestamp;
my $filename;
my $date;
my $relpath;
foreach (@logbook) {
next if /^$/; # skip empty lines
if (/^:/) {
next unless /.py$/; # skip files without .py extension
chomp ($filename = (split /\t/)[1]);
$relpath = substr($filename, 9); # because we're in examples/, drop that part from the path when testing existence
next unless (-e $relpath); # skip files no longer existing
$date = substr($timestamp, 0, 10);
next if ($date eq '2016-04-26');
next if $seen{$filename}; # skip files already displayed with a newer commit
print "$timestamp $filename\n";
$seen{$filename} = 1;
} else {
chomp ($timestamp = $_);
}
}
@TrishGillett
Copy link
Author

See the results here (for the present state of matplotlib): https://gist.github.com/discardthree/2d1316c000d45946bdb4df12d8672070

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment