about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorEric Sagnes <eric.sagnes@gmail.com>2016-07-31 21:58:54 +0900
committerEric Sagnes <eric.sagnes@gmail.com>2016-08-01 18:35:26 +0900
commit85d8b016600925791cbf970f69873dfac1f781cb (patch)
tree51b28920030c6117eff4787700aaee391ae3c81a /lib
parent56575cc0ac289d1f50358297cb72d9cd73f24630 (diff)
downloadnixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar.gz
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar.bz2
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar.lz
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar.xz
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.tar.zst
nixlib-85d8b016600925791cbf970f69873dfac1f781cb.zip
lib: refactor commitIdFromGitRepo with fileContents
Diffstat (limited to 'lib')
-rw-r--r--lib/sources.nix6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/sources.nix b/lib/sources.nix
index 535b04523b57..c1ec02b9c26c 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -44,12 +44,12 @@ rec {
             packedRefsName = toString path + "/packed-refs";
         in if lib.pathExists fileName
            then
-             let fileContent = readFile fileName;
+             let fileContent = lib.fileContents fileName;
                  # Sometimes git stores the commitId directly in the file but
                  # sometimes it stores something like: «ref: refs/heads/branch-name»
-                 matchRef    = match "^ref: (.*)\n$" fileContent;
+                 matchRef    = match "^ref: (.*)$" fileContent;
              in if   isNull matchRef
-                then lib.removeSuffix "\n" fileContent
+                then fileContent
                 else readCommitFromFile path (lib.head matchRef)
            # Sometimes, the file isn't there at all and has been packed away in the
            # packed-refs file, so we have to grep through it: