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:
+4
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user