-
Notifications
You must be signed in to change notification settings - Fork 430
/
gen_version.sh
executable file
·39 lines (32 loc) · 1.07 KB
/
gen_version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
ROOT="$(pwd)"
if BUILD_GIT_REVISION=$(git rev-parse HEAD 2> /dev/null); then if ! git diff-index --quiet HEAD; then BUILD_GIT_REVISION=${BUILD_GIT_REVISION}"-dirty"
fi
else
BUILD_GIT_REVISION=unknown
fi
# Check for local changes
if git diff-index --quiet HEAD --; then
tree_status="Clean"
else
tree_status="Modified"
fi
# Check for git branch and git dirty
BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_DIRTY=$(git diff --no-ext-diff 2> /dev/null | wc -l)
# XXX This needs to be updated to accommodate tags added after building, rather than prior to builds
RELEASE_TAG=$(git describe)
# security wanted VERSION='unknown'
VERSION="${BUILD_GIT_REVISION}"
if [[ -n "${RELEASE_TAG}" ]]; then
VERSION="${RELEASE_TAG}"
fi
# used by core/version
echo buildVersion "${VERSION}"
echo buildGitRevision "${BUILD_GIT_REVISION}"
echo buildUser "$(whoami)"
echo buildHost "$(hostname -f)"
echo buildStatus "${tree_status}"
echo buildTime "$(date +%Y-%m-%d--%T)"
echo buildBranch "${BRANCH}"
echo buildGitDirty "${GIT_DIRTY}"