From 8bc403c56fb856acd4765f5aa4830635c0d9879d Mon Sep 17 00:00:00 2001 From: Shaun Tabone Date: Mon, 15 Jan 2024 16:21:38 +0100 Subject: [PATCH] feat(hooks): added precommit hook --- README.md | 5 +++++ docs/ARCHITECTURE.md | 2 +- src/sync_template.sh | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02ecd97c..66ae056e 100644 --- a/README.md +++ b/README.md @@ -302,6 +302,7 @@ The following hooks are supported (please check [docs/ARCHITECTURE.md](docs/ARCH * `install` is executed after the container has started and after reading and setting up the environment. * `prepull` is executed before the code is pulled from the source repository +* `precommit` is executed before the code is commited * `prepush` is executed before the push is executed, right after the commit * `prepr` is executed before the PR is done @@ -320,6 +321,10 @@ hooks: commands: - echo 'hi, we are within the prepull phase' - echo 'maybe you want to do adjustments on the local code' + precommit: + commands: + - echo 'hi, we are within the precommit phase' + - echo 'maybe you want to add further changes before the code is committed' prepush: commands: - echo 'hi, we are within the prepush phase' diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 73375c6e..843f0ddc 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -35,7 +35,7 @@ GitCommitSync["fa:fa-code-commit Commit the changes"] CheckIsDryRun{"Check if is_dry_run is set to true"} GitPushSync["Push the changes to GitHub"] GitPullRequestSync["fa:fa-code-pull-request Create a pull request on GitHub"] -Hook{{"hooks, prepush | prepush | prepr"}} +Hook{{"hooks, prepull | precommit | prepush | prepr"}} subgraph githubactions["fa:fa-github GitHubActions"] diff --git a/src/sync_template.sh b/src/sync_template.sh index 8408ecb2..e114ef4d 100644 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -94,6 +94,8 @@ if [ -s "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]; then echo "::endgroup::" fi +cmd_from_yml_file "precommit" + echo "::group::commit changes" git add .