Log all git write operations with command, args, and exit code

- Add loggedGit helper that logs 'RUN: git -C <path> <args>' before
  execution and 'EXIT <code>' after (with stderr on failure)
- Refactor gitCommitAll, gitPull, and gitPush to use loggedGit
- Add Logger parameter to gitPull and gitPush
- Update test call sites and syncRepo to pass Logger
This commit is contained in:
2026-05-13 22:19:44 -04:00
parent e0f986a5ee
commit 2f2cc16551
2 changed files with 26 additions and 14 deletions
+4 -2
View File
@@ -13,6 +13,7 @@ spec :: Spec
spec = do
describe "gitPull" $ do
it "pulls changes from remote 'origin'" $ do
logger <- testLogger
withTempGitRepoWithRemote $ \local -> do
-- Make a second commit on local and push to remote
writeFile (local </> "upstream.txt") "pushed to remote"
@@ -27,13 +28,14 @@ spec = do
countBefore `shouldBe` 1
let cfg = defaultRepoConfig{rcPath = local}
(code, _, _) <- gitPull cfg
(code, _, _) <- gitPull logger cfg
code `shouldBe` ExitSuccess
countAfter <- commitCount local
countAfter `shouldBe` 2
it "rebases local commits on top of pulled changes" $ do
logger <- testLogger
withSystemTempDirectory "converge-test-rebase" $ \tmp -> do
let remoteDir = tmp </> "remote.git"
let localDir = tmp </> "local"
@@ -73,7 +75,7 @@ spec = do
-- Pull with --rebase: local commits are rebased on top
-- of the fetched remote commit, yielding a linear history.
let cfg = defaultRepoConfig{rcPath = localDir}
(code, _, _) <- gitPull cfg
(code, _, _) <- gitPull logger cfg
code `shouldBe` ExitSuccess
-- Rebase produces linear history: 3 commits, no merge commit
c <- commitCount localDir