Skip to content

Commit a73b614

Browse files
authored
chore: add pre-commit hooks (#511)
1 parent 4d466d0 commit a73b614

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pyproject.toml
88
.python-version
99
.idea/
1010
.DS_Store
11+
schema/*/build/

.pre-commit-config.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: detect-private-key
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- repo: local
10+
hooks:
11+
- id: update-json-def-files
12+
name: Update json and def files
13+
entry: pre-commit-hooks/update-json-def-files.sh
14+
language: system
15+
files: ^schema/.*/.*-source.yaml$

.requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ ga4gh.gks.metaschema==0.3.0b8
77
sphinx ~= 7.2
88
sphinx-rtd-theme ~= 1.2
99
jupyterlab
10-
notebook
10+
notebook
11+
pre-commit

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Fork the repo at <https://github.com/ga4gh/vrs>.
4444
cd vrs
4545
make devready
4646
source venv/3.12/bin/activate
47+
pre-commit install
4748

4849
If you already cloned the repo, but forgot to include `--recurse-submodules` you can run:
4950

@@ -58,6 +59,9 @@ To create the corresponding def and json files after making changes to the sourc
5859
cd schema
5960
make all
6061

62+
> _Note: We have a custom pre-commit hook to run these commands after you stage a source
63+
> document_
64+
6165
## Contributing to the docs
6266

6367
The VRS specification documentation is written in reStructuredText and located in [docs/source](docs/source/). Commits to this repo are built automatically at <https://vrs.ga4gh.org>.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
REPO_ROOT=$(git rev-parse --show-toplevel)
4+
SCHEMA_DIR="$REPO_ROOT/schema"
5+
DIRS=$(find "$SCHEMA_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
6+
7+
for DIR in $DIRS; do
8+
cd "$DIR" || exit 1
9+
10+
make_output=$(make all)
11+
12+
if [[ "$make_output" == "make: Nothing to be done for \`all\'." ]]; then
13+
echo "No changes to source files in $DIR."
14+
else
15+
echo "Source files updated in $DIR, adding changes to commit."
16+
git add $(git ls-files --modified json def)
17+
fi
18+
done
19+
20+
exit 0

submodules/gks-common

0 commit comments

Comments
 (0)