on master help sign in
command: Rename thunk checkout dir to 'unpacked'
commit310aad69b1d04d54072cf24b0319595d2640898e authorElliot Cameron <eacameron@gmail.com> dateWed 25 Mar 2020, 11:57 (7 years ago) parent03e05eb
2 files changed+11−6
lib/command/src/Obelisk/Command/Thunk.hs+5−3 lib/selftest/src/Obelisk/SelfTest.hs+6−3
lib/command/src/Obelisk/Command/Thunk.hs+5−3
@@ -203,7 +203,7 @@ data ReadThunkError
203203 deriving (Show)
204204
205205unpackedDirName :: FilePath
206−unpackedDirName = "_"
206+unpackedDirName = "unpacked"
207207
208208attrCacheFileName :: FilePath
209209attrCacheFileName = ".attr-cache"
@@ -551,7 +551,8 @@ let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256
551551 } else (import <nixpkgs> {}).fetchFromGitHub {
552552 inherit owner repo rev sha256 fetchSubmodules private;
553553 };
554−in if builtins.pathExists ./_ then ./_ else fetch (builtins.fromJSON (builtins.readFile ./github.json))
554+ json = builtins.fromJSON (builtins.readFile ./github.json);
555+in if builtins.pathExists ./unpacked then ./unpacked else fetch json
555556|]
556557
557558parseGitHubJsonBytes :: LBS.ByteString -> Either String ThunkPtr
@@ -642,7 +643,8 @@ let fetch = {url, rev, branch ? null, sha256 ? null, fetchSubmodules ? false, pr
642643 } else (import <nixpkgs> {}).fetchgit {
643644 url = realUrl; inherit rev sha256;
644645 };
645−in if builtins.pathExists ./_ then ./_ else fetch (builtins.fromJSON (builtins.readFile ./git.json))
646+ json = builtins.fromJSON (builtins.readFile ./git.json);
647+in if builtins.pathExists ./unpacked then ./unpacked else fetch json
646648|]
647649
648650parseGitJsonBytes :: LBS.ByteString -> Either String ThunkPtr
lib/selftest/src/Obelisk/SelfTest.hs+6−3
@@ -241,7 +241,7 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
241241 run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch]
242242 runOb_ ["thunk", "pack", toTextIgnore dir]
243243 runOb_ ["thunk", "unpack", toTextIgnore dir]
244− branch' <- run gitPath ["-C", toTextIgnore $ dir </> ("_" :: FilePath), "rev-parse", "--abbrev-ref", "HEAD"]
244+ branch' <- run gitPath ["-C", toTextIgnore $ dir </> unpackedDirName, "rev-parse", "--abbrev-ref", "HEAD"]
245245 liftIO $ assertEqual "" branch (T.strip branch')
246246
247247 it "can pack and unpack plain git repos" $
@@ -256,7 +256,7 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
256256 ["default.nix", "src.nix", "github.json" :: FilePath]
257257
258258 runOb_ ["thunk", "unpack", repo]
259− chdir (fromText repo </> ("_" :: FilePath)) $ do
259+ chdir (fromText repo </> unpackedDirName) $ do
260260 unpackHash <- revParseHead
261261 assertRevEQ origHash unpackHash
262262
@@ -399,7 +399,7 @@ testThunkPack executable args path' = withTempFile repoDir "test-file" $ \file h
399399 git $ gitUserConfig <> [ "stash" ]
400400 ensureThunkPackFails "has stashes"
401401 where
402− repoDir = path' </> ("_" :: FilePath)
402+ repoDir = path' </> unpackedDirName
403403
404404-- | Blocks until a non-empty line is available
405405hGetLineSkipBlanks :: MonadIO m => Handle -> m Text
@@ -460,3 +460,6 @@ getFreePorts n = Socket.withSocketsDo $ do
460460 sock <- Socket.socket (Socket.addrFamily addr) (Socket.addrSocketType addr) (Socket.addrProtocol addr)
461461 Socket.bind sock (Socket.addrAddress addr)
462462 pure sock
463+
464+unpackedDirName :: FilePath
465+unpackedDirName = "unpacked"