Skip to content

Commit

Permalink
added instruction for configuring pre-commit hook into setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
Formasitchijoh committed Feb 13, 2025
1 parent 956dbc4 commit 0671225
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 3 additions & 5 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/bin/bash

# Notify that the pre-commit hook is running
echo "Pre-commit hook is running..."
echo "⚡ Pre-commit hook is running..."

# Run Rubocop with parallel processing
bundle exec rubocop --parallel

# Check the status of Rubocop
if [ $? -ne 0 ]; then
echo "🔴 Linting failed! Please fix the offenses before committing."
echo -e "🔴 Linting failed! Please fix the offenses before committing."
echo "You can run 'bundle exec rubocop -a' to auto-correct the issues."
exit 1
fi

# Notify that there are no linting issues and the commit can proceed
echo "✅ No linting issues found. Proceeding with commit.\n"
echo -e "🟢 No linting issues found. Proceeding with commit.\n"
14 changes: 12 additions & 2 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ If you know your way around Rails, here's the very short version. Some additiona
10. **Building assets:**
* `yarn start` to built the development version
* `yarn build` to generate the production version
11. Finally, start rails with `guard` or `rails s`and open http://localhost:3000 in a web browser.
12. Now, you're up and running!!
11. (Recommended) Configure Git
* `git config core.hooksPath .git-hooks` to recognize the .git-hooks directory as the hooks directory
* `chmod +x .git-hooks/pre-commit` to make the pre-commit hook executable
12. Finally, start rails with `guard` or `rails s`and open http://localhost:3000 in a web browser.
13. Now, you're up and running!!

## Detailed instructions

Expand Down Expand Up @@ -148,6 +151,13 @@ If you know your way around Rails, here's the very short version. Some additiona

- (Optional) Set up a [`post-merge`](https://git-scm.com/docs/githooks#_post_merge) hook to update all dependencies if `package.json` or `Gemfile` changes.
- Copy `.git-hooks/pull-update-deps` to `.git/hooks/post-merge`

- (Recommended) Set up a [`pre-commit`](https://git-scm.com/docs/githooks#_pre-commit) hook to run linting before making a commit
- `git config core.hooksPath .git-hooks` Configure Git to recognize the .git-hooks directory as the hooks directory
- `chmod +x .git-hooks/pre-commit` Make the pre-commit hook executable



## Initialize
1. **Migrate the development and test databases**
- $ `rake db:migrate`
Expand Down

0 comments on commit 0671225

Please sign in to comment.