From: PatR Date: Wed, 7 Mar 2018 01:16:49 +0000 (-0800) Subject: nhversioning update X-Git-Tag: NetHack-3.6.1_RC01~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03da0190fbbddeb9ece12aa7792a6c6e6fbcb160;p=nethack nhversioning update Update dat/gitinfo.txt if the current branch is different from the one recorded in the file, not just when the commit hash is different. Make the usual output less verbose so that it fits within 80 columns. --- diff --git a/DEVEL/hooksdir/NHgithook.pm b/DEVEL/hooksdir/NHgithook.pm index 0d586cfb7..2f14ae114 100644 --- a/DEVEL/hooksdir/NHgithook.pm +++ b/DEVEL/hooksdir/NHgithook.pm @@ -75,21 +75,28 @@ sub nhversioning { die "git rev-parse failed" unless(length $git_sha and length $git_branch); if (open my $fh, '<', 'dat/gitinfo.txt') { - while(my $line = <$fh>) { + my $hashok = 0; + my $branchok = 0; + while (my $line = <$fh>) { if ((index $line, $git_sha) >= 0) { - close $fh; - print "No update made to dat/gitinfo.txt, existing githash=".$git_sha."\n"; - return; + $hashok++; + } + if ((index $line, $git_branch) >= 0) { + $branchok++; } } close $fh; + if ($hashok && $branchok) { + print "dat/gitinfo.txt unchanged, githash=".$git_sha."\n"; + return; + } } else { print "WARNING: Can't find dat directory\n" unless(-d "dat"); } if (open my $fh, '>', 'dat/gitinfo.txt') { print $fh 'githash='.$git_sha."\n"; print $fh 'gitbranch='.$git_branch."\n"; - print "An updated dat/gitinfo.txt was written, githash=".$git_sha."\n"; + print "dat/gitinfo.txt updated, githash=".$git_sha."\n"; } else { print "WARNING: Unable to open dat/gitinfo.txt: $!\n"; }