Keep your Gitlab's CODEOWNERS file up to date with this linter.
gitlab-codeowners-linter makes sure that the CODEOWNERS file is formatted respecting the following rules:
- every section must be sorted alphabetically
- within a section, paths must be ordered alphabetically
- paths in a section must be unique
- there must be no empty lines between paths
- paths must exist
- there must not be duplicated sections
The linter can run in check or autofix mode.
Install the library with
git clone git@github.com:Qarik-Group/gitlab-codeowners-linter.git
cd gitlab-codeowners-linter
pip install .
You need to pass the path to the CODEOWNERS file to the linter. It can be done via positional argument or with the --codeowners_file
with the path to the CODEOWNERS file.
The linter by default will run in autofix mode. If you just want to check your file without modifying it use --no_autofix
.
You can use this linter with pre-commit
by adding the following hook in your .pre-commit-config.yaml
file.
repos:
- repo: https://github.com/Qarik-Group/gitlab-codeowners-linter
rev: v1.0.2
hooks:
- id: gitlab-codeowners-linter
args: ['--codeowners_file=path/to/your/CODEOWNERS/file']
Note: with pre-commit
the usage of --codeowners_file
is optional, it only speeds up the linter