]> granicus.if.org Git - nethack/commitdiff
nhversioning update
authorPatR <rankin@nethack.org>
Wed, 7 Mar 2018 01:16:49 +0000 (17:16 -0800)
committerPatR <rankin@nethack.org>
Wed, 7 Mar 2018 01:16:49 +0000 (17:16 -0800)
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.

DEVEL/hooksdir/NHgithook.pm

index 0d586cfb77eb93b35d3927c48ebb6a5ec2835977..2f14ae11411933fcf5f512ab86469bfd1e2fc481 100644 (file)
@@ -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";
     }