Add sha256 digest

This commit is contained in:
Reynir Björnsson 2024-01-06 13:14:49 +01:00
parent 3964928563
commit 636850a7ba
1 changed files with 6 additions and 1 deletions

7
import-tars.perl Normal file → Executable file
View File

@ -20,6 +20,7 @@
use strict;
use Getopt::Long;
use Digest::SHA;
my $metaext = '';
@ -43,6 +44,10 @@ foreach my $tar_file (@ARGV)
$tar_file =~ m,([^/]+)$,;
my $tar_name = $1;
my $sha = Digest::SHA->new("256");
$sha->addfile($tar_file);
my $tar_sha256 = $sha->hexdigest;
if ($tar_name =~ s/\.(tar\.gz|tgz)$//) {
open(I, '-|', 'gunzip', '-c', $tar_file)
or die "Unable to gunzip -c $tar_file: $!\n";
@ -164,7 +169,7 @@ foreach my $tar_file (@ARGV)
$have_top_dir = 0 if $top_dir ne $1;
}
my $commit_msg = "Imported from $tar_file.";
my $commit_msg = "Imported from $tar_file.\n\nSHA256:$tar_sha256";
my $this_committer_name = $committer_name;
my $this_committer_email = $committer_email;
my $this_author_name = $author_name;