adding local git hooks

This commit is contained in:
Brian 2022-03-30 13:23:17 -06:00
parent 4b46d9631d
commit f96e7eb0aa
Signed by: brian
GPG Key ID: DE1A5390A3B84CD8
3 changed files with 41 additions and 0 deletions

15
git-hooks/post-checkout Normal file
View File

@ -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

11
git-hooks/post-commit Normal file
View File

@ -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

15
git-hooks/post-update Normal file
View File

@ -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