k3s/scripts/git_version.sh
Brad Davidson c67c7a983c Remove remaining references to drone
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 96ed4393c1)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-12-09 23:51:43 -08:00

25 lines
555 B
Bash
Executable file

#!/bin/bash
GIT_TAG=$TAG
TREE_STATE=clean
COMMIT=$GITHUB_SHA
if [ -d .git ]; then
if [ -z "$GIT_TAG" ]; then
GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
fi
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
TREE_STATE=dirty
fi
COMMIT=$(git log -n3 --pretty=format:"%H %ae" | grep -v ' drone@localhost$' | cut -f1 -d\ | head -1)
if [ -z "${COMMIT}" ]; then
COMMIT=$(git rev-parse HEAD || true)
fi
fi
export GIT_TAG
export TREE_STATE
export COMMIT
export DIRTY