Eric Blake wrote:

> On 01/06/2011 02:44 AM, Jim Meyering wrote:
>>> gnulib-commit-check:
>>>     git submodule foreach test '$$(git rev-parse origin)' \
>>>       = '"$$(git merge-base --independent origin $$sha1)"'
>>
>> Thanks again for the fine test.
>> It passed my tests, so I propose this in your name:
>>
>>>From 8ba2dc9163f753c4953e8686f2b611d4e2a3ae84 Mon Sep 17 00:00:00 2001
>> From: Eric Blake <ebl...@redhat.com>
>> Date: Thu, 6 Jan 2011 10:35:18 +0100
>> Subject: [PATCH] maint.mk: add pre-release check to ensure submodule
>> commits are public
>
> Yes, feel free to push that in my name to gnulib.
>
>> +submodule-checks = no-submodule-changes public-submodule-commit
>
> If someone complains about these two tests being git-centric, a solution
> for a project using maint.mk with a different VCS would be to make
> submodule-checks defined via ?=, so that it can be overridden in cfg.mk
> to an empty macro to skip git submodule consistency checks.  But I'm
> okay using = instead of ?= and waiting until someone requests that extra
> flexibility, if you don't want to change it now.

Good idea.
I've also made the test silently skip when there is no .git/ directory,
just like no-submodule-changes rule does.

One more iteration:

>From 807533b8c9cec5320db9cf7e0746d229bd0700a6 Mon Sep 17 00:00:00 2001
From: Eric Blake <ebl...@redhat.com>
Date: Thu, 6 Jan 2011 10:35:18 +0100
Subject: [PATCH] maint.mk: add pre-release check to ensure submodule commits 
are public

* top/maint.mk (public-submodule-commit): New rule.
(submodule-checks): New variable.
(alpha beta stable): Depend on the variable.
---
 ChangeLog    |    7 +++++++
 top/maint.mk |   18 +++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6b99e92..5e319f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-01-06  Eric Blake  <ebl...@redhat.com>
+
+       maint.mk: add pre-release check to ensure submodule commits are public
+       * top/maint.mk (public-submodule-commit): New rule.
+       (submodule-checks): New variable.
+       (alpha beta stable): Depend on the variable.
+
 2011-01-05  Pádraig Brady <p...@draigbrady.com>
        and Jim Meyering  <meyer...@redhat.com>

diff --git a/top/maint.mk b/top/maint.mk
index 5545e69..f892304 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1118,9 +1118,25 @@ no-submodule-changes:
          : ;                                                           \
        fi

+submodule-checks ?= no-submodule-changes public-submodule-commit
+
+# Ensure that each sub-module commit we're using is public.
+# Without this, it is too easy to tag and release code that
+# cannot be built from a fresh clone.
+.PHONY: public-submodule-commit
+public-submodule-commit:
+       if test -d $(srcdir)/.git; then                                 \
+         git submodule foreach 'test $$(git rev-parse origin)'         \
+             = '"$$(git merge-base --independent origin $$sha1)"'      \
+           || { echo '$(ME): found non-public submodule commit' >&2;   \
+                exit 1; };                                             \
+       else                                                            \
+         : ;                                                           \
+       fi
+
 .PHONY: alpha beta stable
 ALL_RECURSIVE_TARGETS += alpha beta stable
-alpha beta stable: $(local-check) writable-files no-submodule-changes
+alpha beta stable: $(local-check) writable-files $(submodule-checks)
        test $@ = stable                                                \
          && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$'         \
               || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
--
1.7.3.4

Reply via email to