lib: refactor commitIdFromGitRepo with fileContents

+3 -3
+3 -3
lib/sources.nix
··· 44 packedRefsName = toString path + "/packed-refs"; 45 in if lib.pathExists fileName 46 then 47 - let fileContent = readFile fileName; 48 # Sometimes git stores the commitId directly in the file but 49 # sometimes it stores something like: «ref: refs/heads/branch-name» 50 - matchRef = match "^ref: (.*)\n$" fileContent; 51 in if isNull matchRef 52 - then lib.removeSuffix "\n" fileContent 53 else readCommitFromFile path (lib.head matchRef) 54 # Sometimes, the file isn't there at all and has been packed away in the 55 # packed-refs file, so we have to grep through it:
··· 44 packedRefsName = toString path + "/packed-refs"; 45 in if lib.pathExists fileName 46 then 47 + let fileContent = lib.fileContents fileName; 48 # Sometimes git stores the commitId directly in the file but 49 # sometimes it stores something like: «ref: refs/heads/branch-name» 50 + matchRef = match "^ref: (.*)$" fileContent; 51 in if isNull matchRef 52 + then fileContent 53 else readCommitFromFile path (lib.head matchRef) 54 # Sometimes, the file isn't there at all and has been packed away in the 55 # packed-refs file, so we have to grep through it: