guard against inserting a NEWS entry into a block for a prior release
authorJim Meyering <meyering@redhat.com>
Tue, 22 Apr 2008 08:45:21 +0000 (10:45 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 22 Apr 2008 08:45:21 +0000 (10:45 +0200)
Without a guard like this, it is far too easy to apply a patch
prepared against a preceding release, and not notice that a NEWS
entry is inserted into the wrong block.
* maint.mk (sc_immutable_NEWS): New rule.
(update-NEWS-hash): New rule to update the hard-coded hash.

maint.mk

index 46bc8b6..e2a8e1c 100644 (file)
--- a/maint.mk
+++ b/maint.mk
@@ -42,6 +42,7 @@ endif
 
 PREV_VERSION := $(shell cat $(prev_version_file))
 VERSION_REGEXP = $(subst .,\.,$(VERSION))
+PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
 
 ifeq ($(VC),$(GIT))
 this-vc-tag = v$(VERSION)
@@ -425,6 +426,22 @@ sc_perl_coreutils_test:
              exit 1; } || :;                                           \
        fi
 
+NEWS_hash = \
+  $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
+     $(srcdir)/NEWS | md5sum -)
+
+# Ensure that we don't accidentally insert an entry into an old NEWS block.
+old_NEWS_hash = c58d611d93d218181ed77f81ff2395ff  -
+sc_immutable_NEWS:
+       @if test -f $(srcdir)/NEWS; then                                \
+         test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : ||              \
+           { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
+       fi
+
+# Update the hash stored above.  Do this after each release.
+update-NEWS-hash: NEWS
+       perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" $(ME)
+
 # Ensure that the c99-to-c89 patch applies cleanly.
 patch-check:
        rm -rf src-c89 $@.1 $@.2