Skip to content

Commit

Permalink
Merge pull request #1162 from python-gitlab/chore/pre-commit-config
Browse files Browse the repository at this point in the history
chore(env): add pre-commit and commit-msg hooks
  • Loading branch information
max-wittig committed Aug 30, 2020
2 parents 28aa17e + 82070b2 commit 97d8261
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.json
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
}
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,22 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v3.0.0
hooks:
- id: commitlint
additional_dependencies: ['@commitlint/config-conventional']
stages: [commit-msg]

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v3.0.0
hooks:
- id: commitlint-travis
additional_dependencies: ['@commitlint/config-conventional']
stages: [manual]
9 changes: 6 additions & 3 deletions .travis.yml
Expand Up @@ -14,10 +14,13 @@ jobs:
include:
- stage: lint
name: commitlint
python: 3.8
script:
- npm install -g @commitlint/cli @commitlint/config-conventional
- 'echo "module.exports = {extends: [\"@commitlint/config-conventional\"]}" > commitlint.config.js'
- npx commitlint --from=origin/master
- pip3 install pre-commit
- pre-commit run --hook-stage manual commitlint-travis
cache:
directories:
- $HOME/.cache/pre-commit
- stage: lint
name: black_lint
dist: bionic
Expand Down
27 changes: 21 additions & 6 deletions README.rst
Expand Up @@ -99,27 +99,42 @@ You can contribute to the project in multiple ways:
* Add unit and functional tests
* Everything else you can think of

Development workflow
--------------------

Before contributing, please make sure you have `pre-commit <https://pre-commit.com>`_
installed and configured. This will help automate adhering to code style and commit
message guidelines described below:

.. code-block:: bash
cd python-gitlab/
pip3 install --user pre-commit
pre-commit install -t pre-commit -t commit-msg --install-hooks
Please provide your patches as GitHub pull requests. Thanks!

Commit message guidelines
-------------------------

We enforce commit messages to be formatted using the `conventional-changelog <https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines>`_.
This leads to more readable messages that are easy to follow when looking through the project history.

Please provide your patches as github pull requests. Thanks!

Code-Style
----------

We use black as code formatter, so you'll need to format your changes using the
`black code formatter
<https://github.com/python/black>`_.
<https://github.com/python/black>`_. Pre-commit hooks will validate/format your code
when committing. You can then stage any changes ``black`` added if the commit failed.

Just run
To format your code according to our guidelines before committing, run:

.. code-block:: bash
cd python-gitlab/
pip3 install --user black
black .
to format your code according to our guidelines.
Running unit tests
------------------
Expand Down

0 comments on commit 97d8261

Please sign in to comment.