File: check-commit.sh

package info (click to toggle)
pmdk 1.13.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,944 kB
  • sloc: ansic: 126,815; sh: 21,543; cpp: 9,413; python: 5,893; makefile: 3,119; perl: 2,294; pascal: 1,442
file content (57 lines) | stat: -rwxr-xr-x 1,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2022, 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)
body=$(git log --format="%b" -n 1 $1)

if [[ $subject =~ ^Merge.* ]]; then
	# skip
	exit 0
fi

if [[ $subject =~ ^Revert.* ]]; then
	# skip
	exit 0
fi

if [[ $body =~ "git-subtree-dir: src/deps/miniasync" ]]; then
	# skip
	exit 0
fi

# valid area names
AREAS="pmem\|pmem2\|log\|blk\|obj\|pool\|set\|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

ignore_long_link_lines="!/^http/"
commit_len=$(git log --format="%s%n%b" -n 1 $1 | awk ${ignore_long_link_lines} | 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