Skip to content

Commit 4b0d128

Browse files
committed
pre-commit things
1 parent 8fcd034 commit 4b0d128

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ repos:
2424
rev: 0.6.1
2525
hooks:
2626
- id: nbstripout
27+
- repo: local
28+
hooks:
29+
- id: prevent-commit-to-main
30+
name: Prevent Commit to Main Branch
31+
entry: ./prevent_commit_to_main.sh
32+
language: script
33+
stages: [commit]

README.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,19 @@ An example input file can be found in the docs/examples directory in the distrib
8585
4. Run the command (see above)
8686

8787
An example output is also present in the example data and you can compare your output to this file. The example was processed with a muD of 2.5, though for experimentation you can try processing data with different muD values.
88+
89+
Contributing
90+
------------
91+
We welcome contributors from the community. Please consider posting issues, and taking issues and posting PRs.
92+
93+
To ensure code quality and to prevent accidental commits into the default branch, please set up the use of our pre-commit
94+
hooks.
95+
96+
1. modify the permissions to executable on the bash script called `prevent_commit_to_main.sh` in this directory: `chmod +x prevent_commit_to_main.sh`
97+
2. install pre-commit in your working environment `conda install pre-commit`
98+
3. initialize pre-commit (one time only) `pre-commit install`
99+
100+
Thereafter your code will be linted by black and isort and checked against flake8 before you can commit.
101+
If it fails by black or isort, just rerun and it should pass (black and isort will modify the files so should
102+
pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before
103+
trying to commit again

prevent_commit_to_main.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!"C:\\Program Files\\Git\\usr\\bin\\bash.exe"
2+
##!/bin/sh
3+
4+
branch="$(git rev-parse --abbrev-ref HEAD)"
5+
6+
if [ "$branch" = "main" ]; then
7+
echo "You are on the main branch. Committing to the main branch is not allowed."
8+
exit 1
9+
fi

0 commit comments

Comments
 (0)