Skip to content

Commit

Permalink
chore: add commit message format requirements
Browse files Browse the repository at this point in the history
Refs HAUKI-602
  • Loading branch information
danipran committed Jan 16, 2024
1 parent e9db25b commit 77da13e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
default_language_version:
python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit, manual]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -23,3 +25,9 @@ repos:
hooks:
- id: isort
args: [--check]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.10.0
hooks:
- id: commitlint
stages: [commit-msg, manual]
additional_dependencies: ["@commitlint/config-conventional"]
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ docker compose up dev

and open your browser to http://127.0.0.1:8000/.

Run tests with
Run tests with

```
docker compose run dev test
Expand Down Expand Up @@ -104,7 +104,7 @@ pip install -r requirements.txt
pip install -r requirements-dev.txt
```
Copy the development config file example `config_dev.env.example` to `config_dev.env`
Copy the development config file example `config_dev.env.example` to `config_dev.env`
(feel free to edit the configuration file if you have any settings you wish to change):
```
cp config_dev.env.example config_dev.env
Expand All @@ -129,7 +129,7 @@ and open your browser to http://127.0.0.1:8000/.
#### Pre-commit hooks
Before committing files to the repository it's advisable to use the configured pre-commit hooks (see [`.pre-commit-config.yaml`](./.pre-commit-config.yaml)). The CI pipeline will fail if the files are not formatted correctly.

pre-commit is included in the requirements-dev.txt. After cloning the repository you should install the requirements and then install the hooks by running:

```
Expand All @@ -144,6 +144,14 @@ You can at any time run the following command if you would like to check all of
pre-commit run --all-files
```

## Commit message format

New commit messages must adhere to the [Conventional Commits](https://www.conventionalcommits.org/)
specification, and line length is limited to 72 characters.

When [`pre-commit`](https://pre-commit.com/) is in use, [`commitlint`](https://github.com/conventional-changelog/commitlint)
checks new commit messages for the correct format.

## Importing data

Currently, importing *resources* from Helsinki metropolitan area unit registry (TPREK) is supported. Import all resources from [TPREK API](https://www.hel.fi/palvelukarttaws/restpages/ver4.html) by
Expand All @@ -167,7 +175,7 @@ Import library opening hours from the kirjastot.fi API for all resources that ha
python manage.py hours_import kirjastot --openings
```
This imports opening hours for the libraries starting from today and ending one year in the future. If you wish to specify another start date, you may use
This imports opening hours for the libraries starting from today and ending one year in the future. If you wish to specify another start date, you may use
```
python manage.py hours_import kirjastot --openings --date 2021-01-01
Expand Down
10 changes: 10 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Configuration = {
extends: ['@commitlint/config-conventional'],
rules: {
'header-max-length': [2, 'always', 72],
'body-max-line-length': [2, 'always', 72],
'body-leading-blank': [2, 'always'],
},
};

module.exports = Configuration;

0 comments on commit 77da13e

Please sign in to comment.