Merge pull request #1624 from NoahGorny/enforce-pre-commit

Enforce pre commit take 2
pull/1694/head
Noah Gorny 2020-10-29 19:55:55 +02:00 committed by GitHub
commit 3f318914fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 3 deletions

View File

@ -0,0 +1,27 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
# fail_fast: true
minimum_pre_commit_version: 1.18.1
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-added-large-files
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 1.11.0
hooks:
- id: git-check # Configure in .gitattributes
- id: shellcheck
exclude: ".bats$"
- id: shfmt
exclude: ".bats$"
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
hooks:
# - id: forbid-crlf
- id: remove-crlf

6
.shellcheckrc 100644
View File

@ -0,0 +1,6 @@
# We use colors and not assigned
disable=SC2154
# Hard to fix
disable=SC2155
# shellcheck is wrong on some
disable=SC2034

View File

@ -12,19 +12,39 @@ os: linux
dist: xenial
cache:
directories:
- "${HOME}/.cache/pip"
- "${HOME}/.cache/pre-commit"
- "${HOME}/.pre-commit-venv"
- "${HOME}/bin"
- /usr/lib/python3.8
jobs:
include:
- language: go
go: "1.14"
name: Ubuntu 18.04
dist: bionic
sudo: required
before_script:
GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt;
curl https://pre-commit.com/install-local.py | python3 -
script:
pre-commit run --files `cat clean_files.txt`;
- <<: *native_job
name: Ubuntu 16.04
- <<: *native_job
name: Ubuntu 18.04
dist: bionic
- <<: *native_job
name: MacOS xcode9.4
os: osx
osx_image: xcode9.4 # Default xcode on Travis.
- <<: *native_job
name: MacOS xcode11.5
os: osx

View File

@ -64,3 +64,11 @@ These items are subject to change. When making changes to the internal functiona
Plugins can define a function that will be called when the plugin is being disabled.
The callback name should be `{PLUGIN_NAME}_on_disable`, you can see `gitstatus` for usage example.
## Using the pre-commit hook
Note the file .pre-commit-config.yaml at the top of the repo.
This file configures the behavior of the a pre-commit hook based on [the Pre-Commit framework](https://pre-commit.com/). Please see the site about
installing it (with pip, brew or other tools) then run `pre-commit install` in the repo's root to activate the hook.
For the full use of the tool, you may need to install also other third-party tools, such as
[shellcheck](https://github.com/koalaman/shellcheck/) and [shfmt](https://github.com/mvdan/sh).

0
clean_files.txt 100644
View File

View File

@ -0,0 +1 @@
pre-commit==2.3.0