aboutsummaryrefslogtreecommitdiff
path: root/contrib/shell/git-utils.bash
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/shell/git-utils.bash')
-rw-r--r--contrib/shell/git-utils.bash14
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/shell/git-utils.bash b/contrib/shell/git-utils.bash
new file mode 100644
index 0000000000..37bac1f38d
--- /dev/null
+++ b/contrib/shell/git-utils.bash
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+git_root() {
+ git rev-parse --show-toplevel 2> /dev/null
+}
+
+git_head_version() {
+ local recent_tag
+ if recent_tag="$(git describe --exact-match HEAD 2> /dev/null)"; then
+ echo "${recent_tag#v}"
+ else
+ git rev-parse --short=12 HEAD
+ fi
+}