From f1d9b2980bf85457cb37fba193fbd930ffe4ebac Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 28 Nov 2015 15:56:10 +0000 Subject: [PATCH] Dgit.pm: Provide hashfile() Call site(s) will come later. --- Debian/Dgit.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index fa853741..2555812c 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -8,6 +8,7 @@ use warnings; use POSIX; use IO::Handle; use Config; +use Digest::SHA; BEGIN { use Exporter (); @@ -18,6 +19,7 @@ BEGIN { @EXPORT = qw(setup_sigwarn debiantag server_branch server_ref stat_exists link_ltarget + hashfile fail ensuredir executable_on_path waitstatusmsg failedcmd cmdoutput cmdoutput_errok @@ -229,6 +231,13 @@ sub link_ltarget ($$) { link $old, $new or die "link $old $new: $!"; } +sub hashfile ($) { + my ($fn) = @_; + my $h = Digest::SHA->new(256); + $h->addfile($fn); + return $h->hexdigest(); +} + sub git_rev_parse ($) { return cmdoutput qw(git rev-parse), "$_[0]~0"; } -- 2.30.2