From 46773a15b3af302c3fb2a6e31fb589553a903099 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Mon, 20 Jan 2020 00:44:07 +0100 Subject: nixos/version: fix case where .git is a symlink Before c9214c394b248e1f26e45dbe1be2bd82363af3a6 and 9d396d2e426b9a765de0b8999aa214f1259633e6 if .git is symlink the version would gracefully default to no git revision. With those changes an exception is thrown instead. This introduces a new function `pathIsGitRepo` that checks if `commitIdFromGitRepo` fails without error so we don't have to reimplement this logic again and can fail gracefully. --- lib/trivial.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/trivial.nix') diff --git a/lib/trivial.nix b/lib/trivial.nix index 940ec1a3d59..a281cd70fb0 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -191,7 +191,7 @@ rec { let revisionFile = "${toString ./..}/.git-revision"; gitRepo = "${toString ./..}/.git"; - in if builtins.pathExists gitRepo + in if lib.pathIsGitRepo gitRepo then lib.commitIdFromGitRepo gitRepo else if lib.pathExists revisionFile then lib.fileContents revisionFile else default; -- cgit 1.4.1