From 938e1f8c96773cd1f0ffdebd215dc847c9aae987 Mon Sep 17 00:00:00 2001 From: Brian Rogers Date: Wed, 22 Jun 2022 10:47:12 -0600 Subject: [PATCH] updated git hooks --- git-hooks/post-checkout | 12 +++++++++++- git-hooks/post-commit | 10 ++++++++++ git-hooks/post-update | 10 ++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/git-hooks/post-checkout b/git-hooks/post-checkout index 7f606c5..7cd01cb 100644 --- a/git-hooks/post-checkout +++ b/git-hooks/post-checkout @@ -1,5 +1,15 @@ #!/usr/bin/env bash - + +SHORT_HASH=$(git rev-parse --short HEAD) +sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env + +DIRTY_STATE=$(git diff --stat) +if [ -n "$DIRTY_STATE" ]; then + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=true/" .env +else + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=false/" .env +fi + GIT_TAG=$(git tag --points-at HEAD) if [ -n "$GIT_TAG" ]; then sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"${GIT_TAG}\"/" .env diff --git a/git-hooks/post-commit b/git-hooks/post-commit index 630fa42..acecd9f 100644 --- a/git-hooks/post-commit +++ b/git-hooks/post-commit @@ -1,4 +1,14 @@ #!/usr/bin/env bash + +SHORT_HASH=$(git rev-parse --short HEAD) +sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env + +DIRTY_STATE=$(git diff --stat) +if [ -n "$DIRTY_STATE" ]; then + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=true/" .env +else + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=false/" .env +fi SHORT_HASH=$(git rev-parse --short HEAD) sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env diff --git a/git-hooks/post-update b/git-hooks/post-update index 7f606c5..c2b1c96 100644 --- a/git-hooks/post-update +++ b/git-hooks/post-update @@ -1,4 +1,14 @@ #!/usr/bin/env bash + +SHORT_HASH=$(git rev-parse --short HEAD) +sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env + +DIRTY_STATE=$(git diff --stat) +if [ -n "$DIRTY_STATE" ]; then + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=true/" .env +else + sed -i "/^GIT_DIRTY_STATE=.*/ s//GIT_TAG=false/" .env +fi GIT_TAG=$(git tag --points-at HEAD) if [ -n "$GIT_TAG" ]; then