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

View file

@ -15,6 +15,7 @@ EXCLUDED_FILES = [
def run() -> None:
parser = argparse.ArgumentParser()
add_default_linter_arguments(parser)
parser.add_argument('--no-gitlint', action='store_true', help='Disable gitlint')
args = parser.parse_args()
linter_config = LinterConfig(args)
@ -27,6 +28,10 @@ def run() -> None:
linter_config.external_linter('flake8', ['flake8'], ['py'],
description="Standard Python linter (config: .flake8)")
if not args.no_gitlint:
linter_config.external_linter('gitlint', ['tools/lint-commits'],
description="Git Lint for commit messages")
@linter_config.lint
def custom_py() -> int:
"""Runs custom checks for python files (config: tools/linter_lib/custom_check.py)"""