This commit is contained in:
Joey Hess 2015-12-15 15:34:28 -04:00
parent 0ddcaae9c1
commit cdd27b8920
Failed to extract signature
11 changed files with 54 additions and 43 deletions

View file

@ -18,12 +18,13 @@ module Command (
stopUnless,
whenAnnexed,
ifAnnexed,
lookupFile,
isBareRepo,
module ReExported
) where
import Common.Annex
import qualified Backend
import Annex.WorkTree
import qualified Git
import Types.Command as ReExported
import Types.Option as ReExported
@ -100,13 +101,5 @@ stop = return Nothing
stopUnless :: Annex Bool -> Annex (Maybe a) -> Annex (Maybe a)
stopUnless c a = ifM c ( a , stop )
{- Modifies an action to only act on files that are already annexed,
- and passes the key on to it. -}
whenAnnexed :: (FilePath -> Key -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
whenAnnexed a file = ifAnnexed file (a file) (return Nothing)
ifAnnexed :: FilePath -> (Key -> Annex a) -> Annex a -> Annex a
ifAnnexed file yes no = maybe no yes =<< Backend.lookupFile file
isBareRepo :: Annex Bool
isBareRepo = fromRepo Git.repoIsLocalBare