Skip to content

Commit

Permalink
Add basic framework for pre-commit
Browse files Browse the repository at this point in the history
This adds a standardized set of pre-commit checks which replicates
my (PWL) existing checks.
  • Loading branch information
phillord committed May 17, 2024
1 parent 7040db3 commit 90f1a49
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: untracked-file
name: Untracked Files
language: system
entry: ./dev/untracked-files.sh
files: NONE
always_run: true
stages: [pre-commit, pre-push]
- id: not-rfc
name: Not RFC
language: system
entry: ./dev/not-rfc.sh
files: NONE
always_run: true
stages: [pre-commit, pre-push]
- id: run-tests
name: Running Test
language: system
entry: make pre-commit
files: NONE
always_run: true
stages: [pre-commit, pre-push]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-added-large-files

6 changes: 6 additions & 0 deletions dev/not-rfc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

branch=$(git branch --show-current)
if [ "$branch" = "rfc" ]; then
exit 0
fi
8 changes: 8 additions & 0 deletions dev/untracked-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -eu

files=$(git ls-files --other --directory --exclude-standard)
if [ "$files" ]; then
echo There are untracked files: $files
exit 1
fi

0 comments on commit 90f1a49

Please sign in to comment.