Merge remote-tracking branch 'origin/NetHack-3.6.0'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|___/\___|\_/\___|_\___/ .__/\___|_|
|
||||
|_|
|
||||
|
||||
$NHDT-Date: 1518800857 2018/02/16 17:07:37 $
|
||||
$NHDT-Date: 1519228647 2018/02/21 15:57:27 $
|
||||
|
||||
Welcome to the NetHack Infrastructure Developer's Guide.
|
||||
|
||||
@@ -25,6 +25,7 @@ CONTENTS
|
||||
5. variable expansion
|
||||
6. reserved names
|
||||
7. nhadd/nhcommit
|
||||
8. hooks
|
||||
------------------------------------------------------------------------------
|
||||
1. email
|
||||
Email to devteam@nethack.org will usually get a response, but it may take a
|
||||
@@ -37,7 +38,8 @@ The public NetHack git repository is available (read-only) at:
|
||||
or
|
||||
https://github.com/NetHack/NetHack.git
|
||||
|
||||
XXX need to discuss what branches are available
|
||||
Branches:
|
||||
NetHack-3.6.0 The 3.6.0 release code and subsequent fixes and additions.
|
||||
------------------------------------------------------------------------------
|
||||
3. bug reporting
|
||||
Please use the form at http://www.nethack.org/common/contact.html (or send
|
||||
@@ -94,7 +96,8 @@ C. Configure the repository:
|
||||
-v verbose
|
||||
-n dry run
|
||||
You can re-run nhgitset.pl as often as needed; occasionally we will
|
||||
update it and ask you to run it again.
|
||||
update it (or something it installs) and you will need to run it again
|
||||
so the changes take effect.
|
||||
D. aliases
|
||||
Two aliases are installed by nhgitset.pl:
|
||||
nhadd
|
||||
@@ -211,3 +214,19 @@ D. Using your own hooks
|
||||
"perldoc DEVEL/hooksdir/nhsub".
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
8. hooks
|
||||
|
||||
nhgitset.pl also installs hooks into .git/hooks. These hooks provide
|
||||
a framework which allows local hook code to co-exist with hook code we
|
||||
supply - see DEVEL/hooksdir/NHgithook.pm for details.
|
||||
|
||||
We currently use the following hooks:
|
||||
post-checkout
|
||||
post-commit
|
||||
post-merge
|
||||
These are used to generate dat/gitinfo.txt which provides the data that
|
||||
ends up available through the game command #version and the command line
|
||||
option --version.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
33
DEVEL/gitinfo.pl
Normal file
33
DEVEL/gitinfo.pl
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#STARTUP-START
|
||||
BEGIN {
|
||||
# OS hackery has to be duplicated in each of the hooks :/
|
||||
# first the directory separator
|
||||
my $DS = quotemeta('/');
|
||||
my $PDS = '/';
|
||||
# msys: POSIXish over a Windows filesystem (so / not \ but \r\n not \n).
|
||||
# temporarily removed because inconsistent behavior
|
||||
# if ($^O eq "msys")
|
||||
# {
|
||||
# $/ = "\r\n";
|
||||
# $\ = "\r\n";
|
||||
# }
|
||||
if($^O eq "MSWin32"){
|
||||
$DS = quotemeta('\\');
|
||||
$PDS = '\\';
|
||||
}
|
||||
$gitdir = `git rev-parse --git-dir`;
|
||||
chomp $gitdir;
|
||||
push(@INC, $gitdir.$PDS."hooks");
|
||||
|
||||
# special case for this script only: allow
|
||||
# it to run from DEVEL or $TOP
|
||||
if (-f "hooksdir/NHgithook.pm" || -f "DEVEL/hooksdir/NHgithook.pm"){
|
||||
push(@INC, "DEVEL/hooksdir");
|
||||
}
|
||||
chdir("..") if (-f "hooksdir/NHgithook.pm");
|
||||
}
|
||||
use NHgithook;
|
||||
|
||||
&NHgithook::nhversioning;
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# NHgithook.pm
|
||||
# NetHack Git Hook Module
|
||||
# $NHDT-Date$
|
||||
# $NHDT-Date: 1519164205 2018/02/20 22:03:25 $
|
||||
|
||||
package NHgithook;
|
||||
use Cwd;
|
||||
@@ -60,6 +60,51 @@ sub POST {
|
||||
&do_hook("POST");
|
||||
}
|
||||
|
||||
###
|
||||
### store githash and gitbranch in dat/gitinfo.txt
|
||||
###
|
||||
|
||||
sub nhversioning {
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $git_sha = `git rev-parse HEAD`;
|
||||
$git_sha =~ s/\s+//g;
|
||||
my $git_branch = `git rev-parse --abbrev-ref HEAD`;
|
||||
$git_branch =~ s/\s+//g;
|
||||
die "git rev-parse failed" unless(length $git_sha and length $git_branch);
|
||||
my $exists = 0;
|
||||
|
||||
if (open my $fh, '<', 'dat/gitinfo.txt') {
|
||||
$exists = 1;
|
||||
my $hashok = 0;
|
||||
my $branchok = 0;
|
||||
while (my $line = <$fh>) {
|
||||
if ((index $line, $git_sha) >= 0) {
|
||||
$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') {
|
||||
my $how = ($exists ? "updated" : "created");
|
||||
print $fh 'githash='.$git_sha."\n";
|
||||
print $fh 'gitbranch='.$git_branch."\n";
|
||||
print "dat/gitinfo.txt ".$how.", githash=".$git_sha."\n";
|
||||
} else {
|
||||
print "WARNING: Unable to open dat/gitinfo.txt: $!\n";
|
||||
}
|
||||
}
|
||||
|
||||
# PRIVATE
|
||||
sub do_hook {
|
||||
my($p) = @_;
|
||||
|
||||
@@ -26,5 +26,6 @@ use NHgithook;
|
||||
#STARTUP-END
|
||||
|
||||
&NHgithook::PRE;
|
||||
&NHgithook::nhversioning;
|
||||
&NHgithook::POST;
|
||||
exit 0;
|
||||
|
||||
@@ -26,5 +26,6 @@ use NHgithook;
|
||||
#STARTUP-END
|
||||
|
||||
&NHgithook::PRE;
|
||||
&NHgithook::nhversioning;
|
||||
&NHgithook::POST;
|
||||
exit 0;
|
||||
|
||||
@@ -22,9 +22,11 @@ BEGIN {
|
||||
chomp $gitdir;
|
||||
push(@INC, $gitdir.$PDS."hooks");
|
||||
}
|
||||
|
||||
use NHgithook;
|
||||
#STARTUP-END
|
||||
|
||||
&NHgithook::PRE;
|
||||
&NHgithook::nhversioning;
|
||||
&NHgithook::POST;
|
||||
exit 0;
|
||||
|
||||
Reference in New Issue
Block a user