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