Fix two git operation bugs
- gitCommitAll: abort commit when staging (git add -A) fails, e.g. due to a stale .git/index.lock. Previously the failure was ignored and commit proceeded on an empty or partial index. - gitPull: remove explicit branch argument from git pull --rebase. Passing both remote and branch can conflict with the branch's configured tracking ref, causing 'Cannot rebase onto multiple branches'. Now uses just --rebase <remote>, letting git resolve the tracking branch from config. - Test: index.lock scenario verifies commit is aborted on staging failure.
This commit is contained in:
@@ -54,6 +54,19 @@ spec = do
|
||||
countAfter2 <- commitCount repo
|
||||
countAfter2 `shouldBe` countBefore2
|
||||
|
||||
it "aborts commit when staging fails (e.g. index.lock exists)" $ do
|
||||
logger <- testLogger
|
||||
withTempGitRepo $ \repo -> do
|
||||
-- Create a lock file to make git add -A fail
|
||||
writeFile (repo </> ".git" </> "index.lock") "locked"
|
||||
writeFile (repo </> "new.txt") "new file"
|
||||
countBefore <- commitCount repo
|
||||
(code, _, err) <- gitCommitAll logger repo
|
||||
-- Staging fails, so commit should not happen
|
||||
code `shouldSatisfy` (/= ExitSuccess)
|
||||
err `shouldSatisfy` ("index.lock" `T.isInfixOf`)
|
||||
commitCount repo `shouldReturn` countBefore
|
||||
|
||||
describe "startup sync" $ do
|
||||
it "commits and pushes uncommitted changes on startup" $ do
|
||||
logger <- testLogger
|
||||
|
||||
Reference in New Issue
Block a user