]> granicus.if.org Git - nethack/commitdiff
last gitinfo bit?
authorPatR <rankin@nethack.org>
Sat, 10 Mar 2018 20:55:28 +0000 (12:55 -0800)
committerPatR <rankin@nethack.org>
Sat, 10 Mar 2018 20:55:28 +0000 (12:55 -0800)
If dat/gitinfo.txt is being created from scratch, say so instead of
saying "updated".

DEVEL/hooksdir/NHgithook.pm

index 2f14ae11411933fcf5f512ab86469bfd1e2fc481..435fe6c8d41ece45a0c04f54b6afc1fd931c32ff 100644 (file)
@@ -73,8 +73,10 @@ sub nhversioning {
     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>) {
@@ -94,9 +96,10 @@ sub nhversioning {
        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 updated, githash=".$git_sha."\n";
+        print "dat/gitinfo.txt ".$how.", githash=".$git_sha."\n";
     } else {
        print "WARNING: Unable to open dat/gitinfo.txt: $!\n";
     }