mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-14 17:12:26 +08:00
up
This commit is contained in:
26
server/build/git-hash.sh
Executable file
26
server/build/git-hash.sh
Executable 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}"
|
||||
Reference in New Issue
Block a user