lint: Setup gitlint.

Setup gitlint for developers to write well formatted
commit messages.

Note: .gitlint, gitlint-rules.py and lint-commits
are taken directly from zulip/zulip with minor changes.
This commit is contained in:
LoopThrough-i-j 2021-02-25 09:43:09 +05:30 committed by Tim Abbott
parent f8cd424495
commit cce18ed11b
5 changed files with 193 additions and 0 deletions

27
tools/lint-commits Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# This file is copied from the original tools/commit-message-lint at zulip/zulip,
# Edited at Line 14 Col 97 (zulip -> python-zulip-api)
# Please don't edit here; instead update the zulip/zulip copy and then resync this file.
# Lint all commit messages that are newer than upstream/master if running
# locally or the commits in the push or PR Gh-Actions.
# The rules can be found in /.gitlint
if [[ "
$(git remote -v)
" =~ '
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)zulip/python-zulip-api(\.git|/)?\ \(fetch\)'
' ]]; then
range="${BASH_REMATCH[1]}/master..HEAD"
else
range="upstream/master..HEAD"
fi
commits=$(git log "$range" | wc -l)
if [ "$commits" -gt 0 ]; then
# Only run gitlint with non-empty commit lists, to avoid a printed
# warning.
gitlint --commits "$range"
fi