reorder repo parameters last
Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators.
This commit is contained in:
parent
2ff8915365
commit
bf460a0a98
46 changed files with 338 additions and 390 deletions
|
@ -28,11 +28,9 @@ check = do
|
|||
when (b == Annex.Branch.name) $ error $
|
||||
"cannot uninit when the " ++ b ++ " branch is checked out"
|
||||
where
|
||||
current_branch = do
|
||||
g <- gitRepo
|
||||
b <- liftIO $
|
||||
Git.pipeRead g [Params "rev-parse --abbrev-ref HEAD"]
|
||||
return $ head $ lines $ B.unpack b
|
||||
current_branch = head . lines . B.unpack <$> revhead
|
||||
revhead = inRepo $ Git.pipeRead
|
||||
[Params "rev-parse --abbrev-ref HEAD"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withFilesInGit startUnannex, withNothing start]
|
||||
|
@ -53,12 +51,11 @@ perform = next cleanup
|
|||
|
||||
cleanup :: CommandCleanup
|
||||
cleanup = do
|
||||
g <- gitRepo
|
||||
annexdir <- fromRepo $ gitAnnexDir
|
||||
uninitialize
|
||||
mapM_ removeAnnex =<< getKeysPresent
|
||||
liftIO $ removeDirectoryRecursive (gitAnnexDir g)
|
||||
liftIO $ removeDirectoryRecursive annexdir
|
||||
-- avoid normal shutdown
|
||||
saveState
|
||||
liftIO $ do
|
||||
Git.run g "branch" [Param "-D", Param Annex.Branch.name]
|
||||
exitSuccess
|
||||
inRepo $ Git.run "branch" [Param "-D", Param Annex.Branch.name]
|
||||
liftIO $ exitSuccess
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue