@@ -57,7 +57,7 @@ masterBranch = BaseBranch "master"
57
57
callGit :: [String ] -> IO Text
58
58
callGit args = fmap (either undefined id ) $ runNoLoggingT $ Git. callGit userConfig args
59
59
60
- -- Populates the repository with the following history:
60
+ -- | Populates the repository with the following history:
61
61
--
62
62
-- .-- c5 -- c6 <-- intro (pr 6)
63
63
-- /
@@ -67,8 +67,13 @@ callGit args = fmap (either undefined id) $ runNoLoggingT $ Git.callGit userConf
67
67
--
68
68
-- c6 -- c7 -- c8 -- c7f <-------- fixup (pr 8)
69
69
--
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 =
72
77
let writeFile fname msg = Prelude. writeFile (dir </> fname) (msg ++ " \n " )
73
78
appendFile fname msg = Prelude. appendFile (dir </> fname) (msg ++ " \n " )
74
79
git args = callGit $ [" -C" , dir] ++ args
@@ -102,6 +107,8 @@ populateRepository dir =
102
107
gitAdd " roy.txt"
103
108
c3 <- gitCommit " c3: Add new Roy quote"
104
109
110
+ doClone
111
+
105
112
-- Create a branch "ahead", one commit ahead of master.
106
113
gitBranch " ahead" c3
107
114
appendFile " tyrell.txt" " Would you like to be modified?"
@@ -162,11 +169,12 @@ initializeRepository :: FilePath -> FilePath -> IO [Sha]
162
169
initializeRepository originDir repoDir = do
163
170
-- Create the directory for the origin repository, and parent directories.
164
171
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])
170
178
-- Set the author details in the cloned repository as well, to ensure that
171
179
-- there is no implicit dependency on a global Git configuration.
172
180
_
<- callGit [
" -C" , repoDir,
" config" ,
" user.email" ,
" [email protected] " ]
0 commit comments