From 636850a7ba0c663684434b4593c8234bdea2ba82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Sat, 6 Jan 2024 13:14:49 +0100 Subject: [PATCH] Add sha256 digest --- import-tars.perl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) mode change 100644 => 100755 import-tars.perl diff --git a/import-tars.perl b/import-tars.perl old mode 100644 new mode 100755 index f565321..79097ac --- a/import-tars.perl +++ b/import-tars.perl @@ -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;