This commit is contained in:
Zheng Kai
2023-03-29 17:42:41 +08:00
parent 94b04a181a
commit 1b107ed035
36 changed files with 617 additions and 0 deletions

26
server/build/git-hash.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
HASH=$(git rev-parse --short HEAD 2>/dev/null || :)
if [ -z "$HASH" ]; then
echo "empty"
exit
fi
TAG=$(git describe --exact-match "$HASH" 2>/dev/null | head -n 1)
if [ -n "$TAG" ]; then
HASH="$TAG"
fi
ST=$(git status -s -u | head -n 1)
if [ -n "$ST" ]; then
HASH="${HASH}-dirty"
fi
BRANCH=$(git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/")
if [[ "$BRANCH" == *"("* ]]; then
BRANCH=''
else
BRANCH="${BRANCH}:"
fi
echo "${BRANCH}${HASH}"