gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 01/05: build: update git hooks logic


From: gnunet
Subject: [gnunet] 01/05: build: update git hooks logic
Date: Wed, 18 Jan 2023 05:56:22 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit c225268743b7571b1b6a326e34e002b3a4f40d2f
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jan 17 15:13:35 2023 +0900

    build: update git hooks logic
---
 contrib/conf/commit-msg         | 34 ++++++++++++++++++++++++++++++++++
 contrib/conf/prepare-commit-msg | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/contrib/conf/commit-msg b/contrib/conf/commit-msg
new file mode 100644
index 000000000..daa526270
--- /dev/null
+++ b/contrib/conf/commit-msg
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# use as .git/hooks/commit-msg
+
+COMMIT_MSG_FILE=$1
+
+exec 1>&2
+
+RET=0
+changed=$(git diff --cached --name-only)
+
+for f in $changed;
+do
+ # Only headers in include
+ if echo $f | grep \src\/include\/.\*\.h\$  > /dev/null
+ then
+   RET=1
+   # Check if it has a ChangeLog line
+   if cat $COMMIT_MSG_FILE | grep \^ChangeLog: > /dev/null
+   then
+       RET=0
+       break
+   fi
+ fi
+done
+
+# If no ChangeLog line found, abort
+if [ $RET = 1 ];
+then
+  echo "Your commit includes staged changes that indicate an API change which 
requires a ChangeLog line."
+else
+  echo "Your commit does not include API changes"
+fi
+exit $RET
diff --git a/contrib/conf/prepare-commit-msg b/contrib/conf/prepare-commit-msg
new file mode 100644
index 000000000..60aaa2894
--- /dev/null
+++ b/contrib/conf/prepare-commit-msg
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# use as .git/hooks/pre-commit
+
+COMMIT_MSG_FILE=$1
+COMMIT_SOURCE=$2
+SHA1=$3
+
+exec 1>&2
+
+RET=0
+changed=$(git diff --cached --name-only)
+
+for f in $changed;
+do
+ # Only headers in include
+ if echo $f | grep \src\/include\/.\*\.h\$  > /dev/null
+ then
+    RET=1
+ fi
+done
+
+# Only add custom message when there is no commit source
+# ($COMMIT_SOURCE is empty). Otherwise, keep the default message
+# proposed by Git. Possible commit source: message, template,
+# merge, squash or commit.
+if [ $RET = 1 ];
+then
+  if [ -z "$COMMIT_SOURCE" ] || [ "message" == "$COMMIT_SOURCE" ];
+  then
+    hint=$(cat "$COMMIT_MSG_FILE")
+    echo -e "\n# Your commit includes staged changes that indicate an API 
change which requires a ChangeLog line. This info line will be ignored." > 
"$COMMIT_MSG_FILE"
+    echo "ChangeLog: " >> "$COMMIT_MSG_FILE"
+    echo "$hint" >> "$COMMIT_MSG_FILE"
+  fi
+fi
+exit 0

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]