diff options
Diffstat (limited to 'Omni/Agent/Git.hs')
| -rw-r--r-- | Omni/Agent/Git.hs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs index cbb63bd..a7afb20 100644 --- a/Omni/Agent/Git.hs +++ b/Omni/Agent/Git.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -39,7 +38,7 @@ test = git repo ["branch", "-m", "master"] git repo ["config", "user.email", "you@example.com"] git repo ["config", "user.name", "Your Name"] - + -- commit A writeFile (repo <> "/a.txt") "A" git repo ["add", "a.txt"] @@ -48,26 +47,26 @@ test = -- create branch dev git repo ["checkout", "-b", "dev"] - + -- commit B writeFile (repo <> "/b.txt") "B" git repo ["add", "b.txt"] git repo ["commit", "-m", "B"] shaB <- getSha repo "HEAD" - + -- switch back to master git repo ["checkout", "master"] - + -- Test 1: checkout dev checkout repo "dev" current <- getSha repo "HEAD" shaB @=? current - + -- Test 2: checkout master checkout repo "master" current' <- getSha repo "HEAD" shaA @=? current' - + -- Test 3: dirty state writeFile (repo <> "/a.txt") "DIRTY" checkout repo "dev" @@ -77,7 +76,7 @@ test = -- Wait, in dev, a.txt is "A". content <- readFile (repo <> "/a.txt") "A" @=? content - + -- Test 4: untracked file writeFile (repo <> "/untracked.txt") "DELETE ME" checkout repo "master" @@ -103,9 +102,9 @@ getSha dir ref = do checkout :: FilePath -> Text -> IO () checkout repoPath ref = do let r = Text.unpack ref - + Log.info ["git", "checkout", ref, "in", Text.pack repoPath] - + -- Fetch all refs to ensure we have the target git repoPath ["fetch", "--all", "--tags"] @@ -120,7 +119,7 @@ checkout repoPath ref = do -- Update submodules git repoPath ["submodule", "update", "--init", "--recursive"] - + Log.good ["git", "checkout", "complete"] Log.br |
