aboutsummaryrefslogtreecommitdiff
path: root/contrib/shell/git-utils.bash
blob: 37bac1f38d8f087b4b0e073141bdd29a6a33f8ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
}