onlyingroup
* Support "onlyingroup=" in preferred content expressions. * Support --onlyingroup= matching option. Sponsored-by: Jack Hill on Patreon
This commit is contained in:
parent
a17ece1428
commit
fa92383993
8 changed files with 62 additions and 1 deletions
|
@ -188,6 +188,7 @@ preferredContentKeyedTokens pcd =
|
||||||
, ValueToken "inbackend" (usev limitInBackend)
|
, ValueToken "inbackend" (usev limitInBackend)
|
||||||
, ValueToken "metadata" (usev limitMetaData)
|
, ValueToken "metadata" (usev limitMetaData)
|
||||||
, ValueToken "inallgroup" (usev $ limitInAllGroup $ getGroupMap pcd)
|
, ValueToken "inallgroup" (usev $ limitInAllGroup $ getGroupMap pcd)
|
||||||
|
, ValueToken "onlyingroup" (usev $ limitOnlyInGroup $ getGroupMap pcd)
|
||||||
] ++ commonKeyedTokens
|
] ++ commonKeyedTokens
|
||||||
|
|
||||||
preferredContentTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
|
preferredContentTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
|
||||||
|
|
|
@ -28,6 +28,8 @@ git-annex (10.20230627) UNRELEASED; urgency=medium
|
||||||
access.
|
access.
|
||||||
* directory, gcrypt: Remove empty hash directories when dropping content.
|
* directory, gcrypt: Remove empty hash directories when dropping content.
|
||||||
* dropunused: Support --jobs
|
* dropunused: Support --jobs
|
||||||
|
* Support "onlyingroup=" in preferred content expressions.
|
||||||
|
* Support --onlyingroup= matching option.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 26 Jun 2023 13:10:40 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 26 Jun 2023 13:10:40 -0400
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,12 @@ keyMatchingOptions' =
|
||||||
)
|
)
|
||||||
, annexOption (setAnnexState . Limit.addInAllGroup) $ strOption
|
, annexOption (setAnnexState . Limit.addInAllGroup) $ strOption
|
||||||
( long "inallgroup" <> metavar paramGroup
|
( long "inallgroup" <> metavar paramGroup
|
||||||
<> help "match files present in all remotes in a group"
|
<> help "match files present in all repositories in a group"
|
||||||
|
<> hidden
|
||||||
|
)
|
||||||
|
, annexOption (setAnnexState . Limit.addOnlyInGroup) $ strOption
|
||||||
|
( long "onlyingroup" <> metavar paramGroup
|
||||||
|
<> help "match files that are only present in repositories in the group"
|
||||||
<> hidden
|
<> hidden
|
||||||
)
|
)
|
||||||
, annexOption (setAnnexState . Limit.addMetaData) $ strOption
|
, annexOption (setAnnexState . Limit.addMetaData) $ strOption
|
||||||
|
|
25
Limit.hs
25
Limit.hs
|
@ -509,6 +509,31 @@ limitInAllGroup getgroupmap groupname = Right $ MatchFiles
|
||||||
present <- S.fromList <$> Remote.keyLocations key
|
present <- S.fromList <$> Remote.keyLocations key
|
||||||
return $ S.null $ want `S.difference` present
|
return $ S.null $ want `S.difference` present
|
||||||
|
|
||||||
|
{- Skip files that are only present in repositories that are not in the
|
||||||
|
- group. -}
|
||||||
|
addOnlyInGroup :: String -> Annex ()
|
||||||
|
addOnlyInGroup groupname = addLimit $ limitOnlyInGroup groupMap groupname
|
||||||
|
|
||||||
|
limitOnlyInGroup :: Annex GroupMap -> MkLimit Annex
|
||||||
|
limitOnlyInGroup getgroupmap groupname = Right $ MatchFiles
|
||||||
|
{ matchAction = \notpresent mi -> do
|
||||||
|
m <- getgroupmap
|
||||||
|
let want = fromMaybe S.empty $ M.lookup (toGroup groupname) $ uuidsByGroup m
|
||||||
|
if S.null want
|
||||||
|
then return False
|
||||||
|
else checkKey (check notpresent want) mi
|
||||||
|
, matchNeedsFileName = False
|
||||||
|
, matchNeedsFileContent = False
|
||||||
|
, matchNeedsKey = True
|
||||||
|
, matchNeedsLocationLog = True
|
||||||
|
, matchDesc = "inallgroup" =? groupname
|
||||||
|
}
|
||||||
|
where
|
||||||
|
check notpresent want key = do
|
||||||
|
locs <- S.fromList <$> Remote.keyLocations key
|
||||||
|
let present = locs `S.difference` notpresent
|
||||||
|
return $ not $ S.null $ present `S.intersection` want
|
||||||
|
|
||||||
{- Adds a limit to skip files not using a specified key-value backend. -}
|
{- Adds a limit to skip files not using a specified key-value backend. -}
|
||||||
addInBackend :: String -> Annex ()
|
addInBackend :: String -> Annex ()
|
||||||
addInBackend = addLimit . limitInBackend
|
addInBackend = addLimit . limitInBackend
|
||||||
|
|
|
@ -127,6 +127,12 @@ in either of two repositories.
|
||||||
Matches only when git-annex believes content is present in
|
Matches only when git-annex believes content is present in
|
||||||
all repositories in the specified group.
|
all repositories in the specified group.
|
||||||
|
|
||||||
|
* `--onlyingroup=groupname`
|
||||||
|
|
||||||
|
Matches only when git-annex believes content is present in at least one
|
||||||
|
repository that is in the specified group, and is not present in any
|
||||||
|
repositories that are not in the specified group.
|
||||||
|
|
||||||
* `--smallerthan=size`
|
* `--smallerthan=size`
|
||||||
* `--largerthan=size`
|
* `--largerthan=size`
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,12 @@ elsewhere to allow removing it).
|
||||||
Matches only files that git-annex believes are present in all repositories
|
Matches only files that git-annex believes are present in all repositories
|
||||||
in the specified group.
|
in the specified group.
|
||||||
|
|
||||||
|
* `onlyingroup=groupname`
|
||||||
|
|
||||||
|
Matches files that git-annex believes are present in at least one
|
||||||
|
repository that is in the specified group, and are not present in any
|
||||||
|
repositories that are not in the specified group.
|
||||||
|
|
||||||
* `smallerthan=size` / `largerthan=size`
|
* `smallerthan=size` / `largerthan=size`
|
||||||
|
|
||||||
Matches only files whose content is smaller than, or larger than the
|
Matches only files whose content is smaller than, or larger than the
|
||||||
|
|
14
doc/todo/comment_1_98d09316dc39619203e507f862716bab._comment
Normal file
14
doc/todo/comment_1_98d09316dc39619203e507f862716bab._comment
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 1"""
|
||||||
|
date="2023-07-31T18:41:03Z"
|
||||||
|
content="""
|
||||||
|
Matches files that git-annex believes are present in at least one
|
||||||
|
repository that is in the specified group, and are not present in any
|
||||||
|
repositories that are not in the specified group.
|
||||||
|
|
||||||
|
That's a pretty simple description and it allows matching when a repository
|
||||||
|
is in the specified group but is also in some other groups.
|
||||||
|
|
||||||
|
So that makes me happy with onlyingroup and I implemented it.
|
||||||
|
"""]]
|
|
@ -20,3 +20,5 @@ Maybe you see an easier way, but this is what I came up with. I think an `onlyin
|
||||||
|
|
||||||
Cheers,
|
Cheers,
|
||||||
Yann
|
Yann
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue