From cfdc7552882c0c3a55d1af3ac29938f7324a95a2 Mon Sep 17 00:00:00 2001 From: Nao Ueda Date: Fri, 5 Feb 2021 21:32:49 +0900 Subject: initial commit --- time-getter.pl | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 time-getter.pl diff --git a/time-getter.pl b/time-getter.pl new file mode 100644 index 0000000..5335fbd --- /dev/null +++ b/time-getter.pl @@ -0,0 +1,69 @@ +#!/usr/bin/env perl + +use strict; + +open (F, 'git ls-tree -r HEAD|'); + +my %list; + +# 辞書作る +while () { + my @info = split /\s+/; + + my $filename = $info[-1]; + my $hash = $info[-2]; + + $list{$filename} = $hash; +} + +close(F); + +open (COMMITS, 'git rev-list HEAD |'); + +# timestamp 取りつつ tree を get +my $prevtimestamp; +my $timestamp; +while () { + my $commit = $_; + + (keys %list) or last; + + open (TMP, 'git cat-file -p ' . $commit . '|'); + my $tree; + while () { + if (/tree/) { + my @tmp = split /\s+/; + $tree = $tmp[1]; + next + } + if (/committer/) { + my @tmp = split /\s+/; + $timestamp = $tmp[-2]; + last; + } + } + close(TMP); + + open (BLOBS, "git ls-tree -r $tree |"); + + while () { + my @tmp = split(/\s+/); + my $filename = $tmp[-1]; + my $blobhash = $tmp[-2]; + + if (!$list{$filename}) { + next; + } + + if ($list{$filename} !~ /$blobhash/) { + print $filename . ": " . $prevtimestamp . " \n"; + delete ($list{$filename}); + } + } + + $prevtimestamp = $timestamp; + + close (BLOBS); +} + +close (COMMITS); -- cgit v1.2.3-54-g00ecf