make MatchFiles introspectable

matchNeedsFileContent is not used yet, but shows how to add information
about terminals. That one would be needed for
https://git-annex.branchable.com/todo/sync_fast_import/

Note the tricky bit in Annex.FileMatcher.call where it folds over the
included matcher to propagate the information.

This commit was sponsored by Svenne Krap on Patreon.
This commit is contained in:
Joey Hess 2020-09-24 13:55:19 -04:00
parent 6d95361f35
commit c1b4d76e6b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 146 additions and 66 deletions

View file

@ -78,7 +78,7 @@ checkMatcher matcher mkey afile notpresent notconfigured d
checkMatcher' :: FileMatcher Annex -> MatchInfo -> AssumeNotPresent -> Annex Bool
checkMatcher' matcher mi notpresent =
matchMrun matcher $ \a -> a notpresent mi
matchMrun matcher $ \o -> matchAction o notpresent mi
fileMatchInfo :: RawFilePath -> Annex MatchInfo
fileMatchInfo file = do
@ -264,6 +264,9 @@ usev :: MkLimit Annex -> String -> ParseResult (MatchFiles Annex)
usev a v = Operation <$> a v
call :: Either String (FileMatcher Annex) -> ParseResult (MatchFiles Annex)
call (Right sub) = Right $ Operation $ \notpresent mi ->
matchMrun sub $ \a -> a notpresent mi
call (Right sub) = Right $ Operation $ MatchFiles
{ matchAction = \notpresent mi ->
matchMrun sub $ \o -> matchAction o notpresent mi
, matchNeedsFileContent = any matchNeedsFileContent sub
}
call (Left err) = Left err