updating with tested methods

This commit is contained in:
2022-02-07 15:05:00 -07:00
parent db11d6a432
commit b97b438c52
3 changed files with 46 additions and 15 deletions

17
hooks/local/post-checkout Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
GIT_TAG=$(git tag --points-at HEAD)
#GIT_TAG=$(git describe --exact-match --tags --abbrev=0 2>&1) # alternative way of getting the tag, potentially less stable
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 symbolic-ref -q --short HEAD || git describe --tags --exact-match)
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

4
hooks/local/post-commit Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
SHORT_HASH=$(git rev-parse --short HEAD)
sed -i "/^GIT_HASH=\".*\"/ s//GIT_HASH=\"${SHORT_HASH}\"/" .env