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
10
direnvrc
10
direnvrc
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue