on master help sign in
staticWhich git
commit0d2b963a6cf14cabc57c23d04e0542145eb63b22 authorleon.smith@obsidian.systems <leon.smith@obsidian.systems> dateTue 28 Jan 2020, 16:49 (7 years ago) parent4a6f185
2 files changed+16−12
default.nix+1 lib/selftest/src/Obelisk/SelfTest.hs+15−12
default.nix+1
@@ -71,6 +71,7 @@ let
7171 librarySystemDepends = [
7272 pkgs.cabal-install
7373 pkgs.coreutils
74+ pkgs.git
7475 ];
7576 };
7677 obelisk-snap-extras = self.callCabal2nix "obelisk-snap-extras" (cleanSource ./lib/snap-extras) {};
lib/selftest/src/Obelisk/SelfTest.hs+15−12
@@ -52,11 +52,14 @@ cp = $(staticWhich "cp")
5252cabalPath :: FilePath
5353cabalPath = $(staticWhich "cabal")
5454
55+gitPath :: FilePath
56+gitPath = $(staticWhich "git")
57+
5558gitUserConfig :: [Text]
5659gitUserConfig = ["-c", "user.name=Obelisk Selftest", "-c", "user.email=noreply@example.com"]
5760
5861commit :: Text -> Sh ()
59−commit msg = void $ run "git" $ gitUserConfig <> [ "commit"
62+commit msg = void $ run gitPath $ gitUserConfig <> [ "commit"
6063 , "--no-gpg-sign"
6164 , "--allow-empty"
6265 , "-m"
@@ -102,7 +105,7 @@ main = do
102105 withObeliskImplClean f =
103106 withSystemTempDirectory "obelisk-impl-clean" $ \(fromString -> obeliskImpl) -> do
104107 void . shellyOb verbosity $ chdir obeliskImpl $ do
105− run_ "git" ["clone", "file://" <> toTextIgnore obeliskImplDirtyReadOnly, toTextIgnore obeliskImpl]
108+ run_ gitPath ["clone", "file://" <> toTextIgnore obeliskImplDirtyReadOnly, toTextIgnore obeliskImpl]
106109 f obeliskImpl
107110
108111 withObeliskImplDirty f =
@@ -119,7 +122,7 @@ main = do
119122 -- Setup the ob init cache
120123 void . shellyOb verbosity $ chdir initCache $ do
121124 runOb_ ["init", "--symlink", toTextIgnore obeliskImpl]
122− run_ "git" ["init"]
125+ run_ gitPath ["init"]
123126
124127 f initCache
125128
@@ -156,10 +159,10 @@ main = do
156159 assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
157160 assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
158161
159− revParseHead = T.strip <$> run "git" ["rev-parse", "HEAD"]
162+ revParseHead = T.strip <$> run gitPath ["rev-parse", "HEAD"]
160163
161164 commitAll = do
162− run_ "git" ["add", "."]
165+ run_ gitPath ["add", "."]
163166 commit "checkpoint"
164167 revParseHead
165168
@@ -168,7 +171,7 @@ main = do
168171 pack = runOb ["thunk", "pack", thunk] >> commitAll
169172 unpack = runOb ["thunk", "unpack", thunk] >> commitAll
170173
171− diff a b = run "git" ["diff", a, b]
174+ diff a b = run gitPath ["diff", a, b]
172175
173176 describe "ob init" $ parallel $ do
174177 it "works with default impl" $ inTmp $ \_ -> runOb ["init"]
@@ -253,16 +256,16 @@ main = do
253256
254257 it "unpacks the correct branch" $ withTmp $ \dir -> do
255258 let branch = "master"
256− run_ "git" ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch]
259+ run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch]
257260 runOb_ ["thunk", "pack", toTextIgnore dir]
258261 runOb_ ["thunk", "unpack", toTextIgnore dir]
259− branch' <- chdir dir $ run "git" ["rev-parse", "--abbrev-ref", "HEAD"]
262+ branch' <- chdir dir $ run gitPath ["rev-parse", "--abbrev-ref", "HEAD"]
260263 liftIO $ assertEqual "" branch (T.strip branch')
261264
262265 it "can pack and unpack plain git repos" $
263266 shelly_ $ withSystemTempDirectory "git-repo" $ \dir -> do
264267 let repo = toTextIgnore $ dir </> ("repo" :: String)
265− run_ "git" ["clone", "https://github.com/haskell/process.git", repo]
268+ run_ gitPath ["clone", "https://github.com/haskell/process.git", repo]
266269 origHash <- chdir (fromText repo) revParseHead
267270
268271 runOb_ ["thunk", "pack", repo]
@@ -284,13 +287,13 @@ main = do
284287 it "can change a thunk to the latest version of a desired branch" $ withTmp $ \dir -> do
285288 let branch1 = "master"
286289 branch2 = "develop"
287− run_ "git" ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch1]
290+ run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch1]
288291 runOb_ ["thunk" , "pack", toTextIgnore dir]
289292 runOb_ ["thunk", "update", toTextIgnore dir, "--branch", branch2]
290293
291294 it "doesn't create anything when given an invalid branch" $ withTmp $ \dir -> do
292295 let checkDir dir' = liftIO $ getDirectoryContents $ T.unpack $ toTextIgnore dir'
293− run_ "git" ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", "master"]
296+ run_ gitPath ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", "master"]
294297 runOb_ ["thunk" , "pack", toTextIgnore dir]
295298 startingContents <- checkDir dir
296299 void $ errExit False $ runOb ["thunk", "update", toTextIgnore dir, "--branch", "dumble-palooza"]
@@ -322,7 +325,7 @@ testThunkPack executable args path' = withTempFile (T.unpack $ toTextIgnore path
322325 | code == ExitSuccess -> fail $ "ob thunk pack succeeded when it should have failed with error '" <> show q <> "'"
323326 | q `T.isInfixOf` T.pack (out <> err) -> pure ()
324327 | otherwise -> fail $ "ob thunk pack failed for an unexpected reason, expecting '" <> show q <> "', received: " <> show out <> "\nstderr: " <> err
325− git = chdir path' . run "git"
328+ git = chdir path' . run gitPath
326329 -- Untracked files
327330 ensureThunkPackFails "Untracked files"
328331 void $ git ["add", T.pack file]