From 552616b834008c521f07459290e18bf97cd10774 Mon Sep 17 00:00:00 2001 From: Hugo Persson Date: Sat, 6 Jan 2024 22:54:18 +0100 Subject: [PATCH] Finished feature --- README.md | 1 + git-hooks/pre-commit | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 git-hooks/pre-commit diff --git a/README.md b/README.md index dc5f2d25f..e9a6bcd5a 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,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`) diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit new file mode 100755 index 000000000..d0010ed4f --- /dev/null +++ b/git-hooks/pre-commit @@ -0,0 +1,28 @@ +#!/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..."