on master help sign in
command: Rename thunk checkout dir to 'unpacked'
310aad6Elliot Cameron
lib/command/src/Obelisk/Command/Thunk.hs+5−3
@@ -203,7 +203,7 @@ data ReadThunkError
203 deriving (Show)
203 deriving (Show)
204
204
205unpackedDirName :: FilePath
205unpackedDirName :: FilePath
206−unpackedDirName = "_"
206+unpackedDirName = "unpacked"
207
207
208attrCacheFileName :: FilePath
208attrCacheFileName :: FilePath
209attrCacheFileName = ".attr-cache"
209attrCacheFileName = ".attr-cache"
@@ -551,7 +551,8 @@ let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256
551 } else (import <nixpkgs> {}).fetchFromGitHub {
551 } else (import <nixpkgs> {}).fetchFromGitHub {
552 inherit owner repo rev sha256 fetchSubmodules private;
552 inherit owner repo rev sha256 fetchSubmodules private;
553 };
553 };
554+ json = builtins.fromJSON (builtins.readFile ./github.json);
554−in if builtins.pathExists ./_ then ./_ else fetch (builtins.fromJSON (builtins.readFile ./github.json))
555+in if builtins.pathExists ./unpacked then ./unpacked else fetch json
555|]
556|]
556
557
557parseGitHubJsonBytes :: LBS.ByteString -> Either String ThunkPtr
558parseGitHubJsonBytes :: LBS.ByteString -> Either String ThunkPtr
@@ -642,7 +643,8 @@ let fetch = {url, rev, branch ? null, sha256 ? null, fetchSubmodules ? false, pr
642 } else (import <nixpkgs> {}).fetchgit {
643 } else (import <nixpkgs> {}).fetchgit {
643 url = realUrl; inherit rev sha256;
644 url = realUrl; inherit rev sha256;
644 };
645 };
646+ json = builtins.fromJSON (builtins.readFile ./git.json);
645−in if builtins.pathExists ./_ then ./_ else fetch (builtins.fromJSON (builtins.readFile ./git.json))
647+in if builtins.pathExists ./unpacked then ./unpacked else fetch json
646|]
648|]
647
649
648parseGitJsonBytes :: LBS.ByteString -> Either String ThunkPtr
650parseGitJsonBytes :: LBS.ByteString -> Either String ThunkPtr
lib/selftest/src/Obelisk/SelfTest.hs+6−3
@@ -241,7 +241,7 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
241 run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch]
241 run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch]
242 runOb_ ["thunk", "pack", toTextIgnore dir]
242 runOb_ ["thunk", "pack", toTextIgnore dir]
243 runOb_ ["thunk", "unpack", toTextIgnore dir]
243 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"]
245 liftIO $ assertEqual "" branch (T.strip branch')
245 liftIO $ assertEqual "" branch (T.strip branch')
246
246
247 it "can pack and unpack plain git repos" $
247 it "can pack and unpack plain git repos" $
@@ -256,7 +256,7 @@ main' isVerbose httpManager obeliskRepoReadOnly = withInitCache $ \initCache ->
256 ["default.nix", "src.nix", "github.json" :: FilePath]
256 ["default.nix", "src.nix", "github.json" :: FilePath]
257
257
258 runOb_ ["thunk", "unpack", repo]
258 runOb_ ["thunk", "unpack", repo]
259− chdir (fromText repo </> ("_" :: FilePath)) $ do
259+ chdir (fromText repo </> unpackedDirName) $ do
260 unpackHash <- revParseHead
260 unpackHash <- revParseHead
261 assertRevEQ origHash unpackHash
261 assertRevEQ origHash unpackHash
262
262
@@ -399,7 +399,7 @@ testThunkPack executable args path' = withTempFile repoDir "test-file" $ \file h
399 git $ gitUserConfig <> [ "stash" ]
399 git $ gitUserConfig <> [ "stash" ]
400 ensureThunkPackFails "has stashes"
400 ensureThunkPackFails "has stashes"
401 where
401 where
402− repoDir = path' </> ("_" :: FilePath)
402+ repoDir = path' </> unpackedDirName
403
403
404-- | Blocks until a non-empty line is available
404-- | Blocks until a non-empty line is available
405hGetLineSkipBlanks :: MonadIO m => Handle -> m Text
405hGetLineSkipBlanks :: MonadIO m => Handle -> m Text
@@ -460,3 +460,6 @@ getFreePorts n = Socket.withSocketsDo $ do
460 sock <- Socket.socket (Socket.addrFamily addr) (Socket.addrSocketType addr) (Socket.addrProtocol addr)
460 sock <- Socket.socket (Socket.addrFamily addr) (Socket.addrSocketType addr) (Socket.addrProtocol addr)
461 Socket.bind sock (Socket.addrAddress addr)
461 Socket.bind sock (Socket.addrAddress addr)
462 pure sock
462 pure sock
463+
464+unpackedDirName :: FilePath
465+unpackedDirName = "unpacked"