Skip to content

Commit 04f54b0

Browse files
Merge pull request #13 from calebowens/add-pre-commit-hooks-for-linting
Added in a husky and lint-staged setup
2 parents 79c6529 + a1415f2 commit 04f54b0

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.git_hooks/pre-commit

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Get a list of the staged files
4+
STAGED_RUBY_FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | grep ".rb")
5+
6+
# If ruby_files string is non-zero
7+
if [ ! -z $STAGED_RUBY_FILES ]
8+
then
9+
echo "[Pre commit hook] Running standardrb linting"
10+
11+
# If standardrb returns a non 0 response, exit
12+
docker compose run --rm --no-deps -T web standardrb $STAGED_RUBY_FILES || exit 1
13+
fi

install_git_hooks.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
echo "Installing git hooks\n"
4+
5+
echo "Copying contents of .git_hooks into .git/hooks\n"
6+
cp .git_hooks/* .git/hooks
7+
8+
echo "Install complete!"

readme.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# README
22

3+
## Development environment setup
4+
5+
### Pre-Commit Hooks
6+
7+
Everyone should have pre-commit hooks setup!
8+
9+
1. Run `./install_git_hooks.sh`
10+
11+
3. Voila!
12+
313
## Structure
414

515
- app

0 commit comments

Comments
 (0)