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 if [ -f "${path}/.version-suffix" ]; then
local version="$(< $path/.version-suffix)" local version="$(< $path/.version-suffix)"
elif [ -f "${path}/.git" ]; then elif [ -d "${path}/.git" ]; then
local version="$(< $(< ${path}/.git/HEAD))" local head=$(< ${path}/.git/HEAD)
local regex="ref: (.*)"
if [[ "$head" =~ $regex ]]; then
local version=$(< ".git/${BASH_REMATCH[1]}")
else
local version="$head"
fi
fi fi
local cache=".direnv/cache-${version:-unknown}" local cache=".direnv/cache-${version:-unknown}"
@ -63,4 +69,4 @@ use_nix() {
watch_file default.nix watch_file default.nix
watch_file shell.nix watch_file shell.nix
fi fi
} }