gitinfo.pl: special case code to allow running it from $TOP or DEVEL without

installing the hooks first
NHgithook.pm: add some warnings if nhversioning can't open files
make sure nhversioning fails before opening gitinfo.txt if it can't get valid
 data
This commit is contained in:
keni
2018-02-09 11:48:04 -05:00
parent 65655d2cee
commit cf9cf038f3
6 changed files with 20 additions and 5 deletions

View File

@@ -20,6 +20,13 @@ BEGIN {
$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;

Binary file not shown.

View File

@@ -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;
@@ -72,6 +72,7 @@ sub nhversioning {
$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);
if (open my $fh, '<', 'dat/gitinfo.txt') {
while(my $line = <$fh>) {
@@ -82,11 +83,15 @@ sub nhversioning {
}
}
close $fh;
} 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";
} else {
print "WARNING: Unable to open dat/gitinfo.txt: $!\n";
}
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1513130016 2017/12/13 01:53:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.81 $ */
/* NetHack 3.6 allmain.c $NHDT-Date: 1518193644 2018/02/09 16:27:24 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.86 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -763,7 +763,8 @@ enum earlyarg e_arg;
{
int i, idx;
boolean match = FALSE;
char *userea = (char *)0, *dashdash = "";
char *userea = (char *)0;
const char *dashdash = "";
for (idx = 0; idx < SIZE(earlyopts); idx++) {
if (earlyopts[idx].e == e_arg)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 version.c $NHDT-Date: 1517140532 2018/01/28 11:55:32 $ $NHDT-Branch: nhmall-githash3 $:$NHDT-Revision: 1.50 $ */
/* NetHack 3.6 version.c $NHDT-Date: 1519155525 2018/02/20 19:38:45 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.47 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -46,7 +46,9 @@ char *buf;
#endif
if (details) {
#if defined(RUNTIME_PORT_ID) || defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH)
int c = 0;
#endif
#if defined(RUNTIME_PORT_ID)
char tmpbuf[BUFSZ];
char *tmp = (char *)0;

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# NetHack 3.6 macosx.sh $NHDT-Date: 1518800856 2018/02/16 17:07:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.19 $
# NetHack 3.6 macosx.sh $NHDT-Date: 1517231957 2018/01/29 13:19:17 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.20 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#