diff --git a/src/Converge.hs b/src/Converge.hs index 3655769..6d1ceb6 100644 --- a/src/Converge.hs +++ b/src/Converge.hs @@ -305,7 +305,7 @@ gitPull :: RepoConfig -> IO (ExitCode, Text, Text) gitPull repo = runGitIn (rcPath repo) - ["pull", "--no-edit", T.unpack (rcRemote repo), T.unpack (rcBranch repo)] + ["pull", "--rebase", T.unpack (rcRemote repo), T.unpack (rcBranch repo)] -- | Check if the repository currently has merge conflicts. hasConflicts :: FilePath -> IO Bool diff --git a/test/GitCommitSpec.hs b/test/GitCommitSpec.hs index e0a8399..a1f1584 100644 --- a/test/GitCommitSpec.hs +++ b/test/GitCommitSpec.hs @@ -1,11 +1,9 @@ module GitCommitSpec (spec) where import Converge (gitCommitAll) -import Data.Text (Text) import qualified Data.Text as T import System.Exit (ExitCode (..)) import System.FilePath (()) -import System.IO (writeFile) import Test.Hspec import TestHelper diff --git a/test/GitPullSpec.hs b/test/GitPullSpec.hs index 64d3325..1980b5e 100644 --- a/test/GitPullSpec.hs +++ b/test/GitPullSpec.hs @@ -5,7 +5,6 @@ import qualified Data.Text as T import System.Directory (createDirectory) import System.Exit (ExitCode (..)) import System.FilePath (()) -import System.IO (writeFile) import System.IO.Temp (withSystemTempDirectory) import Test.Hspec import TestHelper @@ -72,13 +71,15 @@ spec = do _ <- runGitIn otherDir ["commit", "-m", "remote commit"] _ <- runGitIn otherDir ["push", "origin", "main"] - -- Pull into local with divergent history. - -- CURRENT BEHAVIOR: git pull --no-edit fails on divergent - -- branches (exit 128). The spec requires rebase instead. - -- When --rebase is implemented, expect ExitSuccess and - -- linear history (commit count = 3). + -- Pull with --rebase: local commits are rebased on top + -- of the fetched remote commit, yielding a linear history. let cfg = defaultRepoConfig {rcPath = localDir} - (code, _, err) <- gitPull cfg - -- Document current gap: divergent pull fails - code `shouldSatisfy` (/= ExitSuccess) - err `shouldSatisfy` ("fast-forward" `T.isInfixOf`) + (code, _, _) <- gitPull cfg + code `shouldBe` ExitSuccess + -- Rebase produces linear history: 3 commits, no merge commit + c <- commitCount localDir + c `shouldBe` 3 + -- Verify no merge commits exist (each commit has exactly 1 parent) + (_, logOut, _) <- runGitIn localDir ["log", "--format=%P", "--all"] + let parentCounts = map (length . words) (lines (T.unpack logOut)) + parentCounts `shouldSatisfy` all (<= 1) diff --git a/test/TestHelper.hs b/test/TestHelper.hs index 3717219..01d7809 100644 --- a/test/TestHelper.hs +++ b/test/TestHelper.hs @@ -22,7 +22,6 @@ import qualified Data.Text as T import System.Directory (createDirectory) import System.Exit (ExitCode) import System.FilePath (()) -import System.IO (writeFile) import System.IO.Temp (withSystemTempDirectory) import System.Process (readProcessWithExitCode)