Feature/Add git pre-commit hook for yarn format (#2840)
* Set up git pre-commit hook for yarn format * Update changelog
This commit is contained in:
parent
a47829082e
commit
170b8acc65
@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added a hint for _Time-Weighted Rate of Return_ (TWR) to the portfolio summary tab on the home page
|
||||
- Added support for REST APIs (`JSON`) via the scraper configuration
|
||||
- Enabled the _Redis_ authentication in the `docker-compose` files
|
||||
- Set up a git-hook to format the code before any commit
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -160,6 +160,7 @@ Ghostfolio is available for various home server systems, including [Runtipi](htt
|
||||
1. Run `yarn install`
|
||||
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
|
||||
1. Run `yarn database:setup` to initialize the database schema
|
||||
1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks
|
||||
1. Start the server and the client (see [_Development_](#Development))
|
||||
1. Open http://localhost:4200/en in your browser
|
||||
1. Create a new user via _Get Started_ (this first user will get the role `ADMIN`)
|
||||
|
26
git-hooks/pre-commit
Executable file
26
git-hooks/pre-commit
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Will check if "yarn format" is run before executing.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
|
||||
echo "Running yarn format"
|
||||
|
||||
# Run the command and loop over its output
|
||||
FILES_TO_STAGE=""
|
||||
i=0
|
||||
while IFS= read -r line; do
|
||||
# Process each line here
|
||||
((i++))
|
||||
if [ $i -le 2 ]; then
|
||||
continue
|
||||
fi
|
||||
if [[ $line == Done* ]]; then
|
||||
break
|
||||
fi
|
||||
FILES_TO_STAGE="$FILES_TO_STAGE $line"
|
||||
|
||||
done < <(yarn format )
|
||||
git add $FILES_TO_STAGE
|
||||
echo "Files formatted. Committing..."
|
Loading…
x
Reference in New Issue
Block a user