File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ die () {
4+ printf ' %s\n' " $* " >&2
5+ exit 1
6+ }
7+
8+ command -v git > /dev/null 2>&1 ||
9+ die " neither chroot-git nor git could be found!"
10+
11+ tip=" $( git rev-list -1 --parents HEAD) "
12+ case " $tip " in
13+ # This is a merge commit, pick last parent
14+ * " " * " " * ) tip=" ${tip##* } " ;;
15+ # This is a non-merge commit, pick itself
16+ * ) tip=" ${tip%% * } " ;;
17+ esac
18+
19+ base=" $( git merge-base origin/HEAD " $tip " ) "
20+
21+ [ $( git rev-list --count " $tip " " ^$base " ) -lt 20 ] || {
22+ echo " ::error title=Branch out of date::Your branch is too out of date. Please rebase on upstream and force-push."
23+ exit 1
24+ }
25+
26+ status=0
27+
28+ for cmt in $( git rev-list --abbrev-commit $base ..$tip )
29+ do
30+ git cat-file commit " $cmt " |
31+ awk -vC=" $cmt " '
32+ # skip header
33+ /^$/ && !msg { msg = 1; next }
34+ !msg { next }
35+ # 3: long-line-is-banned-except-footnote-like-this-for-url
36+ (NF > 2) && (length > 80) { print "::error title=Commit Lint::" C ": long line: " $0; exit 1 }
37+ !subject {
38+ if (length > 50) { print "::warning title=Commit Lint::" C ": subject is a bit long" }
39+ if (!($0 ~ ":")) { print "::error title=Commit Lint::" C ": subject does not follow CONTRIBUTING.md guidelines"; exit 1 }
40+ subject = 1; next
41+ }
42+ /^$/ { body = 1; next }
43+ !body { print "::error title=Commit Lint::" C ": second line must be blank"; exit 1 }
44+ ' || status=1
45+ done
46+ exit $status
You can’t perform that action at this time.
0 commit comments