Skip to content

Commit 06096aa

Browse files
authored
refactor: ♻️ simplify to only setup precommit (#26)
## Description SImplify the command to only setup precommit hooks and run them. <!-- Select quick/in-depth as necessary --> No review needed. ## Checklist - [x] Ran `just run-all`
1 parent 350551d commit 06096aa

File tree

4 files changed

+46
-50
lines changed

4 files changed

+46
-50
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,25 @@ follow the Conventional Commit standard. This will only work if:
5757
Otherwise, you’ll get an error or nothing will happen.
5858

5959
``` bash
60-
spaid_setup_dev_workspace -h
60+
spaid_setup_precommit -h
6161
```
6262

63-
Usage: spaid_setup_dev_workspace \[-h\]
63+
Usage: spaid_setup_precommit \[-h\]
6464

65-
Run this command to either setup up or update your development workspace
66-
to have any helper packages or tools installed and configured. These are
67-
the actions it does currently:
65+
Run this command to setup pre-commit on the repository. It will:
6866

69-
- Installs Python package dependencies (if in a Poetry project)
70-
- Installs pre-commit hooks
71-
- Runs pre-commit hooks on all the files
67+
- Install pre-commit hooks
68+
- Do an initial run of the pre-commit hooks on all the files
7269

7370
This command only works if:
7471

7572
- you are in a local Git repository
7673
- the repository has a file called ‘.pre-commit-config.yaml’
7774

75+
Examples:
76+
77+
spaid_setup_precommit
78+
7879
``` bash
7980
spaid_create_python_files -h
8081
```

README.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spaid_lint_commits_on_branch -h
4848

4949
```{bash}
5050
#| output: asis
51-
spaid_setup_dev_workspace -h
51+
spaid_setup_precommit -h
5252
```
5353

5454
```{bash}

bin/spaid_setup_dev_workspace

Lines changed: 0 additions & 41 deletions
This file was deleted.

bin/spaid_setup_precommit

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/zsh
2+
3+
help_text="
4+
Usage: `basename $0` [-h]
5+
6+
Run this command to setup pre-commit on the repository. It will:
7+
8+
- Install pre-commit hooks
9+
- Do an initial run of the pre-commit hooks on all the files
10+
11+
This command only works if:
12+
13+
- you are in a local Git repository
14+
- the repository has a file called '.pre-commit-config.yaml'
15+
16+
Examples:
17+
18+
spaid_setup_precommit
19+
"
20+
21+
if [[ "$1" == "-h" ]] ; then
22+
echo $help_text
23+
exit 0
24+
fi
25+
26+
precommit_file=$(pwd)/.pre-commit-config.yaml
27+
28+
if [[ ! -f "$precommit_file" ]]
29+
then
30+
echo "Error: No '$precommit_file' found. You need to create one to continue."
31+
exit 1
32+
fi
33+
34+
# Install pre-commit hooks as defined in `.pre-commit-config.yaml`
35+
uvx pre-commit install
36+
uvx pre-commit run --all-files

0 commit comments

Comments
 (0)