mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
fix dereferencing git HEAD
This commit is contained in:
parent
e7df598cd0
commit
983f7b8154
1 changed files with 9 additions and 3 deletions
12
direnvrc
12
direnvrc
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue