ActionGetWanted working

The sim is now basically working!
This commit is contained in:
Joey Hess 2024-09-11 10:32:04 -04:00
parent 07f54668c4
commit a387f40ffb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 114 additions and 65 deletions

View file

@ -5,11 +5,12 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE OverloadedStrings #-}
module Command.Sim where
import Command
import Annex.Sim
import qualified Annex
import Utility.Tmp.Dir
import System.Random
@ -23,16 +24,18 @@ seek :: CmdParams -> CommandSeek
seek _ = do
rng <- initStdGen
repobyname <- mkGetExistingRepoByName
r <- Annex.gitRepo
withTmpDir "sim" $ \tmpdir -> do
let st = emptySimState rng repobyname
let getpath = GetSimRepoPath $ \u -> tmpdir </> fromUUID u
let st = emptySimState rng repobyname getpath
st' <- runSimCommand (CommandInit (RepoName "foo")) st
>>= runSimCommand (CommandTrustLevel (RepoName "foo") "trusted")
>>= runSimCommand (CommandUse (RepoName "bar") "here")
>>= runSimCommand (CommandConnect (RepoName "foo") (RemoteName "bar"))
>>= runSimCommand (CommandAdd "foo" 100000 (RepoName "foo"))
let simdir = \u -> tmpdir </> fromUUID u
st'' <- liftIO $ updateSimRepos r simdir st'
>>= runSimCommand (CommandConnect (RepoName "bar") (RemoteName "foo"))
>>= runSimCommand (CommandAdd "bigfile" 1000000 (RepoName "foo"))
>>= runSimCommand (CommandAction (RepoName "bar") (ActionGitPull (RemoteName "foo")))
>>= runSimCommand (CommandAction (RepoName "bar") (ActionGetWanted (RemoteName "foo")))
st'' <- liftIO $ updateSimRepos st'
liftIO $ print tmpdir
_ <- liftIO $ getLine
return ()