Skip to content

pre-commit things #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Make prevent_commit_to_main.sh executable
run: chmod +x ./prevent_commit_to_main.sh
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
2 changes: 0 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ jobs:
- name: Validate diffpy.labpdfproc
shell: bash -l {0}
run: |
pwd
ls
conda activate test
coverage run -m pytest -s
coverage report -m
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ repos:
rev: 0.6.1
hooks:
- id: nbstripout
- repo: local
hooks:
- id: prevent-commit-to-main
name: Prevent Commit to Main Branch
entry: ./prevent_commit_to_main.sh
language: script
stages: [commit]
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,19 @@ An example input file can be found in the docs/examples directory in the distrib
4. Run the command (see above)

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.

Contributing
------------
We welcome contributors from the community. Please consider posting issues, and taking issues and posting PRs.

To ensure code quality and to prevent accidental commits into the default branch, please set up the use of our pre-commit
hooks.

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`
2. install pre-commit in your working environment `conda install pre-commit`
3. initialize pre-commit (one time only) `pre-commit install`

Thereafter your code will be linted by black and isort and checked against flake8 before you can commit.
If it fails by black or isort, just rerun and it should pass (black and isort will modify the files so should
pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before
trying to commit again
9 changes: 9 additions & 0 deletions prevent_commit_to_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
##!"C:\\Program Files\\Git\\usr\\bin\\bash.exe"

branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "main" ]; then
echo "You are on the main branch. Committing to the main branch is not allowed."
exit 1
fi
Loading