/ contrib / shell / git-utils.bash
git-utils.bash
 1  #!/usr/bin/env bash
 2  
 3  git_root() {
 4      git rev-parse --show-toplevel 2> /dev/null
 5  }
 6  
 7  git_head_version() {
 8      local recent_tag
 9      if recent_tag="$(git describe --exact-match HEAD 2> /dev/null)"; then
10          echo "${recent_tag#v}"
11      else
12          git rev-parse --short=12 HEAD
13      fi
14  }