refactored and generalized pre-command sanity checking
This commit is contained in:
parent
66194684ac
commit
5b74b130a3
38 changed files with 73 additions and 67 deletions
|
@ -19,18 +19,15 @@ import qualified Annex.Branch
|
|||
import Annex.Content
|
||||
|
||||
command :: [Command]
|
||||
command = [repoCommand "uninit" paramPaths seek
|
||||
command = [Command "uninit" paramPaths check seek
|
||||
"de-initialize git-annex and clean out repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withNothing startCheck, withFilesInGit startUnannex, withNothing start]
|
||||
|
||||
startCheck :: CommandStart
|
||||
startCheck = do
|
||||
check :: Annex ()
|
||||
check = do
|
||||
needsRepo
|
||||
b <- current_branch
|
||||
when (b == Annex.Branch.name) $ error $
|
||||
"cannot uninit when the " ++ b ++ " branch is checked out"
|
||||
stop
|
||||
where
|
||||
current_branch = do
|
||||
g <- gitRepo
|
||||
|
@ -38,6 +35,9 @@ startCheck = do
|
|||
Git.pipeRead g [Params "rev-parse --abbrev-ref HEAD"]
|
||||
return $ head $ lines $ B.unpack b
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withFilesInGit startUnannex, withNothing start]
|
||||
|
||||
startUnannex :: FilePath -> CommandStart
|
||||
startUnannex file = do
|
||||
-- Force fast mode before running unannex. This way, if multiple
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue