diff --git a/git-hooks/post-checkout b/git-hooks/post-checkout new file mode 100644 index 0000000..7f606c5 --- /dev/null +++ b/git-hooks/post-checkout @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +GIT_TAG=$(git tag --points-at HEAD) +if [ -n "$GIT_TAG" ]; then + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"${GIT_TAG}\"/" .env +else + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"\"/" .env +fi + +GIT_BRANCH=$(git branch --show-current) +if [ -n "$GIT_BRANCH" ]; then + sed -i "/^GIT_BRANCH=\".*\"/ s//GIT_BRANCH=\"${GIT_BRANCH}\"/" .env +else + sed -i "/^GIT_BRANCH=\".*\"/ s//GIT_BRANCH=\"\"/" .env +fi diff --git a/git-hooks/post-commit b/git-hooks/post-commit new file mode 100644 index 0000000..4a3ab3a --- /dev/null +++ b/git-hooks/post-commit @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +SHORT_HASH=$(git rev-parse --short HEAD) +sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env + +GIT_TAG=$(git tag --points-at HEAD) +if [ -n "$GIT_TAG" ]; then + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"${GIT_TAG}\"/" .env +else + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"\"/" .env +fi \ No newline at end of file diff --git a/git-hooks/post-update b/git-hooks/post-update new file mode 100644 index 0000000..a0681ad --- /dev/null +++ b/git-hooks/post-update @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +GIT_TAG=$(git tag --points-at HEAD) +if [ -n "$GIT_TAG" ]; then + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"${GIT_TAG}\"/" .env +else + sed -i "/^GIT_TAG=\".*\"/ s//GIT_TAG=\"\"/" .env +fi + +GIT_BRANCH=$(git branch --show-current) +if [ -n "$GIT_BRANCH" ]; then + sed -i "/^GIT_BRANCH=\".*\"/ s//GIT_BRANCH=\"${GIT_BRANCH}\"/" .env +else + sed -i "/^GIT_BRANCH=\".*\"/ s//GIT_BRANCH=\"\"/" .env +fi \ No newline at end of file