nhgitset: Deprecate PRE and POST hooks.

nhgitset version 6
prepare for future phases to get rid of those hooks
fix some minor bugs
This commit is contained in:
nhkeni
2026-06-19 20:44:46 -04:00
parent 6d0757fc86
commit 10d87c4b9d
3 changed files with 38 additions and 6 deletions
+5 -4
View File
@@ -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.
+22 -1
View File
@@ -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+<VERFH>;
my $message = join('',<VERFH>);
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<dat/gitinfo.txt>.
Common routines for dealing with nethack.setupversion git config variable.
+11 -1
View File
@@ -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(<IN>){
m/^__END__/ && do {$started =1; next};
print OUT if($started);