diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-11-28 15:56:10 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-07-16 16:47:46 +0100 |
commit | f1d9b2980bf85457cb37fba193fbd930ffe4ebac (patch) | |
tree | ccdca6bba3a18d72f3255425a4a44267b80f7675 | |
parent | ecbd050d62ca87c4298a1344c805db0b93c392e0 (diff) |
Dgit.pm: Provide hashfile()
Call site(s) will come later.
-rw-r--r-- | Debian/Dgit.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index fa85374..2555812 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"; } |