Skip to content

Commit 4873ebe

Browse files
committed
Merge #155: Avoid using --single-branch in tests
Approved-by: rudymatela Auto-deploy: false
2 parents c0a7524 + 581909c commit 4873ebe

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/EventLoopSpec.hs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ masterBranch = BaseBranch "master"
5757
callGit :: [String] -> IO Text
5858
callGit args = fmap (either undefined id) $ runNoLoggingT $ Git.callGit userConfig args
5959

60-
-- Populates the repository with the following history:
60+
-- | Populates the repository with the following history:
6161
--
6262
-- .-- c5 -- c6 <-- intro (pr 6)
6363
-- /
@@ -67,8 +67,13 @@ callGit args = fmap (either undefined id) $ runNoLoggingT $ Git.callGit userConf
6767
--
6868
-- c6 -- c7 -- c8 -- c7f <-------- fixup (pr 8)
6969
--
70-
populateRepository :: FilePath -> IO [Sha]
71-
populateRepository dir =
70+
--
71+
-- The given clone action is called when the repository
72+
-- is only partially populated with:
73+
--
74+
-- c0 -- c1 -- c2 -- c3
75+
populateRepository :: FilePath -> IO () -> IO [Sha]
76+
populateRepository dir doClone =
7277
let writeFile fname msg = Prelude.writeFile (dir </> fname) (msg ++ "\n")
7378
appendFile fname msg = Prelude.appendFile (dir </> fname) (msg ++ "\n")
7479
git args = callGit $ ["-C", dir] ++ args
@@ -102,6 +107,8 @@ populateRepository dir =
102107
gitAdd "roy.txt"
103108
c3 <- gitCommit "c3: Add new Roy quote"
104109

110+
doClone
111+
105112
-- Create a branch "ahead", one commit ahead of master.
106113
gitBranch "ahead" c3
107114
appendFile "tyrell.txt" "Would you like to be modified?"
@@ -162,11 +169,12 @@ initializeRepository :: FilePath -> FilePath -> IO [Sha]
162169
initializeRepository originDir repoDir = do
163170
-- Create the directory for the origin repository, and parent directories.
164171
FileSystem.createDirectoryIfMissing True originDir
165-
shas <- populateRepository originDir
166-
-- Clone with --single-branch, to make sure that we do not have all commits
167-
-- in the repo dir: when this is running for real, we won't have new commits
168-
-- already in the repository either. They need to be fetched.
169-
_ <- callGit ["clone", "--single-branch", "--branch", "master", "file://" ++ originDir, repoDir]
172+
-- Populates the repository. The function 'populateRepository' calls the
173+
-- given callback action in an early point in history before commits in
174+
-- branches other than master are in the repo dir: when this is running for
175+
-- real, we won't have new commits already in the repository either. They
176+
-- need to be fetched.
177+
shas <- populateRepository originDir (void $ callGit ["clone", "file://" ++ originDir, repoDir])
170178
-- Set the author details in the cloned repository as well, to ensure that
171179
-- there is no implicit dependency on a global Git configuration.
172180
_ <- callGit ["-C", repoDir, "config", "user.email", "[email protected]"]

0 commit comments

Comments
 (0)