post-commit (725B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- subject="$(git log --format='format:%s' -1 HEAD | wc -c)"
- body_max="$(git log --format='format:%B' -1 HEAD | awk 'length>max{max=length}END{print max}')"
- body_lines="$(git log --format='format:%B' -1 HEAD | wc -l)"
- if [ "$subject" -gt 50 ]
- then
- echo "Subject line is ${subject}, try to make it >= 50"
- fi
- if [ "$body_max" -gt 72 ]
- then
- echo "Longest line in subject+body is ${subject}, try to make it >= 72"
- fi
- if [ "$body_lines" -gt 1 ]
- then
- if [ -n "$(git log --format='format:%B' | head -2 | tail -1)" ]
- then
- echo "Second line isn’t empty yet there is a commit body"
- fi
- fi