diff options
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Agent/Git.hs | 21 | ||||
| -rw-r--r-- | Omni/Agent/Log.hs | 24 |
2 files changed, 25 insertions, 20 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 diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index 33b9722..c93479b 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -1,5 +1,4 @@ {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -26,14 +25,21 @@ data LogEntry = LogEntry deriving (Show, Eq, Generic) instance FromJSON LogEntry where - parseJSON = Aeson.withObject "LogEntry" <| \v -> - LogEntry - <$> v .: "message" - <*> v .:? "level" - <*> v .:? "toolName" - <*> v .:? "batches" - <*> v .:? "method" - <*> v .:? "path" + parseJSON = + Aeson.withObject "LogEntry" <| \v -> + ( LogEntry + </ (v .: "message") + ) + <*> v + .:? "level" + <*> v + .:? "toolName" + <*> v + .:? "batches" + <*> v + .:? "method" + <*> v + .:? "path" parseLine :: Text -> Maybe LogEntry parseLine line = Aeson.decode <| BSL.fromStrict <| encodeUtf8 line |
