Sign inSign up

thangit93/pre-commit

By thangit93

•Updated about 3 years ago

Docker image to run pre-commit (http://pre-commit.com/)

Image
0

144

thangit93/pre-commit repository overview

⁠Usage

  • Create .pre-commit-config.yaml in the root of your repo. For example:
- repo: git://github.com/pre-commit/pre-commit-hooks
  sha: master  # Use the ref you want to point at
  hooks:
    - { id: check-case-conflict }
    - { id: check-merge-conflict }
    - { id: check-symlinks }
    - { id: check-json }
    - { id: check-yaml }
    - { id: detect-private-key }
    - { id: end-of-file-fixer }
    - { id: trailing-whitespace }
  • Add pre-commit script to .git/hooks/pre-commit
cd $(git rev-parse --show-toplevel)

NAME=$(basename `git rev-parse --show-toplevel`)_precommit
docker ps -a | grep $NAME &> /dev/null
CONTAINER_EXISTS=$?

if [[ CONTAINER_EXISTS -eq 0 ]]; then
    docker stop $NAME && docker rm $NAME
fi
docker run --rm -t -v $(pwd):/pre-commit --name $NAME thangit93/pre-commit pre-commit run --all-files

Tag summary

Content type

Image

Digest

sha256:7e9abef72…

Size

412.1 MB

Last updated

about 3 years ago

docker pull thangit93/pre-commit