From 10d87c4b9d229ad1c5d8a593af0e1c51f2217332 Mon Sep 17 00:00:00 2001 From: nhkeni Date: Fri, 19 Jun 2026 20:44:46 -0400 Subject: [PATCH] nhgitset: Deprecate PRE and POST hooks. nhgitset version 6 prepare for future phases to get rid of those hooks fix some minor bugs --- DEVEL/VERSION | 9 +++++---- DEVEL/hooksdir/NHgithook.pm | 23 ++++++++++++++++++++++- DEVEL/nhgitset.pl | 12 +++++++++++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/DEVEL/VERSION b/DEVEL/VERSION index 3788cb6d5..382eb85f0 100644 --- a/DEVEL/VERSION +++ b/DEVEL/VERSION @@ -1,4 +1,5 @@ -5 -Please see "git log DEVEL" for previous changes. -Make documentation of nhgitset.pl easier to find and -find out about. +6 +PRE and POST hooks will be dropped at some future date - +see https://www.nethack.org/devel/deprecation.html for details. + +See "git log DEVEL" for previous changes. diff --git a/DEVEL/hooksdir/NHgithook.pm b/DEVEL/hooksdir/NHgithook.pm index 065fcd60a..5b90193aa 100644 --- a/DEVEL/hooksdir/NHgithook.pm +++ b/DEVEL/hooksdir/NHgithook.pm @@ -109,7 +109,7 @@ sub version_in_devel { my $version; my $verfile = "$path${PDS}DEVEL${PDS}VERSION"; - open VERFH,"<",$verfile or die "xCan't open $verfile: $!"; + open VERFH,"<",$verfile or die "Can't open $verfile: $!"; $version = 0+; my $message = join('',); close VERFH; @@ -250,7 +250,17 @@ sub do_hook { my($p) = @_; my $hname = $0; $hname =~ s!^((.*$DS)|())(.*)!$1$p-$4!; + my $vig = version_in_git; if(-x $hname){ + if(`git config --bool nethack.NoDepWarn` ne "true\n"){ + print STDERR <<~E_O_M; + WARNING: $p hooks will be going away. See + https://www.nethack.org/devel/deprecation.html + To stop seeing this message, run + git config --bool nethack.NoDepWarn true + E_O_M + } + print TRACE "START $p: $hname\n" if($trace); open TOHOOK, "|-", $hname or die "open $hname: $!"; @@ -370,6 +380,17 @@ Perl module for infrastructure of NetHack Git hooks. Buffers call information so multiple independent actions may be coded for Git hooks and similar Git callouts. +=over 4 + +=item ==> + +As of Git 2.54, multiple actions may be specified for each hook +event - that makes this redundant for hooks and will be removed at +some future time when Git 2.54 (or later) is better distributed. +This should speed up hook processing. + +=back 4 + Maintains C. Common routines for dealing with nethack.setupversion git config variable. diff --git a/DEVEL/nhgitset.pl b/DEVEL/nhgitset.pl index 2c4977895..d1f587b04 100755 --- a/DEVEL/nhgitset.pl +++ b/DEVEL/nhgitset.pl @@ -93,6 +93,16 @@ if($version_old > 0){ if(length $message_new){ print STDERR "Additional information:\n$message_new\n"; } +# This list and the code below will need to be updated if other changes occur +# before this progression is finished. +# 6 announce eventual deprecation of PRE and POST hooks +# 6->7 unset nethack.NoDepWarn, change message, docs in NHgithook.pm +# 7 deprecation of PRE and POST hooks +# 7->8 unset nethack.NoDepWarn, change message, docs in NHgithook.pm and make fail +# 8 PRE and POST throw errors +# 8->9 unset nethack.NoDepWarn, remove code, docs +# 9 removal of PRE and POST code + system('git','config','--unset','nethack.NoDepWarn') unless($opt_n); } } @@ -358,7 +368,7 @@ sub do_file_nhgitset { open IN, "<", $infile or die "Can't open $infile:$!"; open OUT, ">", $outfile or die "Can't open $outfile:$!"; my $started; - print IN "die \"DO NOT RUN THIS FILE\n\""; + print OUT "=pod\n"; while(){ m/^__END__/ && do {$started =1; next}; print OUT if($started);