-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc694df
commit 627cb06
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Relative path to your custom script within your project folder | ||
custom_script_path="./ProjectFolder/scripts/format.sh" | ||
|
||
echo "pre-commit hook: Running ${custom_script_path}" | ||
|
||
# Run the custom script | ||
if [ -f "$custom_script_path" ]; then | ||
# Navigate to the project root directory before running the script | ||
project_root="$(git rev-parse --show-toplevel)" | ||
cd "$project_root" || exit | ||
|
||
# Run the custom script | ||
sh "$custom_script_path" | ||
|
||
# Check the exit status of the script | ||
if [ $? -ne 0 ]; then | ||
echo "Formatting script made changes. Re-stage modified files" | ||
exit 1 | ||
fi | ||
else | ||
echo "${custom_script_path} not found. Commit aborted." | ||
exit 1 | ||
fi |