https://github.com/egen/gitlab-codeowners-linter
gitlab-codeowners-linter is a linter for Gitlab's CODEOWNERS file
https://github.com/egen/gitlab-codeowners-linter
codeowners codeowners-validator gitlab gitlab-ci linter linting
Last synced: 20 days ago
JSON representation
gitlab-codeowners-linter is a linter for Gitlab's CODEOWNERS file
- Host: GitHub
- URL: https://github.com/egen/gitlab-codeowners-linter
- Owner: egen
- License: mit
- Created: 2022-09-09T13:01:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-14T15:43:54.000Z (7 months ago)
- Last Synced: 2025-07-14T19:57:39.211Z (7 months ago)
- Topics: codeowners, codeowners-validator, gitlab, gitlab-ci, linter, linting
- Language: Python
- Homepage:
- Size: 69.3 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gitlab-codeowners-linter
Keep your [Gitlab's CODEOWNERS file](https://docs.gitlab.com/ee/user/project/code_owners.html) up to date with this linter.
## Features
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
- there must not be trailing whitespace
The linter can run in check or autofix mode.
## Usage
Install the library with
```bash
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`.
### Usage with pre-commit
You can use this linter with `pre-commit` by adding the following hook in your `.pre-commit-config.yaml` file.
```yaml
repos:
- repo: https://github.com/Qarik-Group/gitlab-codeowners-linter
rev: v1.0.3
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