summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/check-commit.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/pmdk/utils/check-commit.sh
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pmdk/utils/check-commit.sh')
-rwxr-xr-xsrc/pmdk/utils/check-commit.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/pmdk/utils/check-commit.sh b/src/pmdk/utils/check-commit.sh
new file mode 100755
index 000000000..3985e40c3
--- /dev/null
+++ b/src/pmdk/utils/check-commit.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2016-2020, Intel Corporation
+
+#
+# Used to check whether all the commit messages in a pull request
+# follow the GIT/PMDK guidelines.
+#
+# usage: ./check-commit.sh commit
+#
+
+if [ -z "$1" ]; then
+ echo "Usage: check-commit.sh commit-id"
+ exit 1
+fi
+
+echo "Checking $1"
+
+subject=$(git log --format="%s" -n 1 $1)
+
+if [[ $subject =~ ^Merge.* ]]; then
+ # skip
+ exit 0
+fi
+
+if [[ $subject =~ ^Revert.* ]]; then
+ # skip
+ exit 0
+fi
+
+# valid area names
+AREAS="pmem\|pmem2\|rpmem\|log\|blk\|obj\|pool\|test\|benchmark\|examples\|doc\|core\|common\|daxio\|pmreorder"
+
+prefix=$(echo $subject | sed -n "s/^\($AREAS\)\:.*/\1/p")
+
+if [ "$prefix" = "" ]; then
+ echo "FAIL: subject line in commit message does not contain valid area name"
+ echo
+ `dirname $0`/check-area.sh $1
+ exit 1
+fi
+
+commit_len=$(git log --format="%s%n%b" -n 1 $1 | wc -L)
+
+if [ $commit_len -gt 73 ]; then
+ echo "FAIL: commit message exceeds 72 chars per line (commit_len)"
+ echo
+ git log -n 1 $1 | cat
+ exit 1
+fi