aboutsummaryrefslogtreecommitdiff
path: root/contrib/shell/git-utils.bash
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2021-03-17 12:36:55 -0400
committerCarl Dong <contact@carldong.me>2021-04-05 11:00:21 -0400
commit7753357a7bae98ec775c707b9dec4cea1e945802 (patch)
tree81eb95d504fb71a062c068f1def14298c45b4485 /contrib/shell/git-utils.bash
parente5b49a01f5d0f631e7f08f86ca8a2c2b8213319f (diff)
downloadbitcoin-7753357a7bae98ec775c707b9dec4cea1e945802.tar.xz
guix: Add source-able bash prelude and utils
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
+}