summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi/vc-key.sh
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2017-11-07 16:43:11 +1100
committerChris Johns <chrisj@rtems.org>2017-11-10 13:34:06 +1100
commit6f3fb8a547f5700416744a7dc82b3cb83177c7a8 (patch)
tree5a5869b9dcf63196c0c1ef06b2ccdc4006d48f05 /cpukit/sapi/vc-key.sh
parentpppd/Makefile.am: Add support/include (diff)
downloadrtems-6f3fb8a547f5700416744a7dc82b3cb83177c7a8.tar.bz2
cpukit: Add a Version API.
Provide functions to get the version string, major, minor and revision numbers and the version control identifer that is a unique tag for the version control system. Update #3199.
Diffstat (limited to 'cpukit/sapi/vc-key.sh')
-rwxr-xr-xcpukit/sapi/vc-key.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/cpukit/sapi/vc-key.sh b/cpukit/sapi/vc-key.sh
new file mode 100755
index 0000000000..c628a1e26d
--- /dev/null
+++ b/cpukit/sapi/vc-key.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+git=$(command -v git)
+
+#
+# Git command not found or not a valid git repo is a release.
+#
+vc_ident="release"
+
+if test $# -ge 1; then
+ repo=$1
+ shift
+ if test -d $repo; then
+ cwd=$(pwd)
+ cd $repo
+ if test -n ${git}; then
+ git rev-parse --git-dir > /dev/null 2>&1
+ if test $? == 0; then
+ git status > /dev/null 2>&1
+ if git diff-index --quiet HEAD --; then
+ modified=""
+ else
+ modified="-modified"
+ fi
+ vc_ident="$(git rev-parse --verify HEAD)${modified}"
+ if test $# -ge 1; then
+ if test "${vc_ident}" == "$1"; then
+ vc_ident="matches"
+ fi
+ fi
+ fi
+ fi
+ cd $cwd
+ fi
+fi
+
+echo ${vc_ident}
+
+exit 0