fix dereferencing git HEAD

This commit is contained in:
Jörg Thalheim 2019-10-18 12:33:38 +00:00
parent e7df598cd0
commit 983f7b8154

View file

@ -3,8 +3,14 @@ use_nix() {
if [ -f "${path}/.version-suffix" ]; then
local version="$(< $path/.version-suffix)"
elif [ -f "${path}/.git" ]; then
local version="$(< $(< ${path}/.git/HEAD))"
elif [ -d "${path}/.git" ]; then
local head=$(< ${path}/.git/HEAD)
local regex="ref: (.*)"
if [[ "$head" =~ $regex ]]; then
local version=$(< ".git/${BASH_REMATCH[1]}")
else
local version="$head"
fi
fi
local cache=".direnv/cache-${version:-unknown}"