Skip to content

Commit 16918f2

Browse files
authored
Merge pull request #65 from sbillinge/precommit
pre-commit things
2 parents 5c3eed7 + 87c0c62 commit 16918f2

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-python@v4
17+
- name: Make prevent_commit_to_main.sh executable
18+
run: chmod +x ./prevent_commit_to_main.sh
1719
- uses: pre-commit/[email protected]
1820
with:
1921
extra_args: --all-files

.github/workflows/testing.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
- name: Validate diffpy.labpdfproc
5050
shell: bash -l {0}
5151
run: |
52-
pwd
53-
ls
5452
conda activate test
5553
coverage run -m pytest -s
5654
coverage report -m

.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+
#!/bin/sh
2+
##!"C:\\Program Files\\Git\\usr\\bin\\bash.exe"
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)