Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion template.ini → .commit-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[header]
# header line regex:
pattern = ^(option: |requirements: |doc: |release: ).+$
pattern = ^(option: |requirements: |ci: |doc: |release: ).+$

[body]
# Allow empty body commit message. (i.e. single line commit message).
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/commit-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: commit-format 🔍

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell
- name: commit-format
run: |
git fetch --no-tags --depth=1 origin main
python commit_format/commit_format.py -t .commit-format -v -b origin/main
23 changes: 23 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pylint 🐍

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Pylint 🐍
run: |
pylint $(git ls-files '*.py')
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Python 🐍 distribution 📦 to PyPI
name: Build and Publish

on: push

Expand Down
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A tool to check your commit messages format.

## Supported checkers

Primarly disigned for to check for spelling mistakes in commit messages,
Primarily disigned for to check for spelling mistakes in commit messages,
`commit-format` now comes with various checker allowing to:

- Check that each message lines does not exceed a length limit.
Expand Down Expand Up @@ -49,16 +49,16 @@ $ commit-format -ns

### -t (--template FILE) Template compliance

You can provide a simple INI template to validate the commit header/footer format
You can provide a configuration TOML file template to validate the commit header/footer format
and required symbols.

Usage:

```sh
$ commit-format -t /path/to/template.ini
$ commit-format -t /path/to/.commit-format
```

Template schema (INI):
Template schema (TOML):

- [header]
- pattern: Regex that the first line (header) must match.
Expand All @@ -69,27 +69,33 @@ Template schema (INI):
- required: true/false to require a footer section.
- pattern: Regex that each footer line must match.

Example `template.ini`:
Example `.commit-format`:

```ini
```toml
[header]
pattern = ^(feat: |fix: |doc: |ci: ).+$
# header line regex:
pattern = ^(feat: |fic: |ci: |doc: ).+$

[structure]
[body]
# Allow empty body commit message. (i.e. single line commit message).
allow_empty = false
# Require that header line and body line are separated by an empty line.
blank_line_after_header = true

[footer]
# Require a footer line
required = true
# Footer line regex
pattern = ^(Signed-off-by: ).+$

```

## Behavior option

### -a (--all) Force checking all commits

By default the script will only run on a branch and stop when reaching the base branch.
If run on a base branch direclty, the script will throw an error:
If run on a base branch directly, the script will throw an error:

```sh
$ commit-format
Expand All @@ -114,12 +120,15 @@ As described in [option -a section](#a---all-force-checking-all-commits) the bas
to let the script restrict it's analysis on the commits of a branch.
Default value for the base branch name is `main`.

> When running this script in a CI environment, you may be required to fetch your base branch
> manually. See [github workflow](.github/workflows/commit-format.yml) example.

Usage:

```sh
$ commit-format -b master
$ commit-format -b origin/main
```

### -v (--verbosity)

Diplay debug messages from the script.
Display debug messages from the script.
1 change: 1 addition & 0 deletions commit_format/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# pylint: skip-file
__author__ = 'Alex Fabre'
Loading