skeleton of filter-branch command, with option parser

This commit is contained in:
Joey Hess 2021-05-14 10:59:48 -04:00
parent a71c002ac1
commit a58c90ccf4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 88 additions and 4 deletions

View file

@ -68,6 +68,7 @@ import qualified Command.Unlock
import qualified Command.Lock
import qualified Command.PreCommit
import qualified Command.PostReceive
import qualified Command.FilterBranch
import qualified Command.Find
import qualified Command.FindRef
import qualified Command.Whereis
@ -202,6 +203,7 @@ cmds testoptparser testrunner mkbenchmarkgenerator = map addGitAnnexGlobalOption
, Command.Unused.cmd
, Command.DropUnused.cmd
, Command.AddUnused.cmd
, Command.FilterBranch.cmd
, Command.Find.cmd
, Command.FindRef.cmd
, Command.Whereis.cmd

78
Command/FilterBranch.hs Normal file
View file

@ -0,0 +1,78 @@
{- git-annex command
-
- Copyright 2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.FilterBranch where
import Command
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $
command "filter-branch" SectionMaintenance
"filter information from the git-annex branch"
paramPaths (seek <$$> optParser)
data FilterBranchOptions = FilterBranchOptions
{ includeFiles :: CmdParams
, keyOptions :: Maybe KeyOptions
, includeKeyInformationFor :: [DeferredParse UUID]
, excludeKeyInformationFor :: [DeferredParse UUID]
, includeAllKeyInformation :: Bool
, includeRepoConfigFor :: [DeferredParse UUID]
, excludeRepoConfigFor :: [DeferredParse UUID]
, includeAllRemoteConfig :: Bool
, includeGlobalConfig :: Bool
, excludeGlobalConfig :: Bool
}
optParser :: CmdParamsDesc -> Parser FilterBranchOptions
optParser desc = FilterBranchOptions
<$> cmdParams desc
<*> optional parseKeyOptions
<*> many
( parseRepositoryOption "include-key-information-for"
"include key information for a repository"
)
<*> many
( parseRepositoryOption "exclude-key-information-for"
"exclude key information for a repository"
)
<*> switch
( long "include-all-key-information"
<> help "include key information for all repositories"
)
<*> many
( parseRepositoryOption "include-repo-config-for"
"include configuration specific to a repository"
)
<*> many
( parseRepositoryOption "exclude-repo-config-for"
"exclude configuration specific to a repository"
)
<*> switch
( long "include-all-repo-config"
<> help "include configuration of all repositories"
)
<*> switch
( long "include-global-config"
<> help "include global configuration"
)
<*> switch
( long "exclude-global-config"
<> help "exclude global configuration"
)
parseRepositoryOption :: String -> String -> Parser (DeferredParse UUID)
parseRepositoryOption s h = parseUUIDOption <$> strOption
( long s
<> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
<> help h
<> completeRemotes
)
seek :: FilterBranchOptions -> CommandSeek
seek o = do
error "TODO"

View file

@ -15,10 +15,11 @@ and git-annex there will automatically merge that into its git-annex
branch. This allows publishing some information from your git-annex branch,
without publishing the whole thing.
Other ways to avoid publishing information from a git-annex branch
include [[git-annex-forget]](1), the `annex.private` git config,
and the `--private` option to [[git-annex-initremote](1). Those are much
easier to use, but this provides full control for those who need it.
Other ways to avoid publishing information from a git-annex branch,
or remove information from it include [[git-annex-forget]](1), the
`annex.private` git config, and the `--private` option to
[[git-annex-initremote](1). Those are much easier to use, but this
provides full control for those who need it.
With no options, no information at all will be included from the git-annex
branch. Use options to specify what to include. All options can be specified
@ -83,6 +84,8 @@ multiple times.
* `--include-all-repo-config`
Include the configuration of all repositories.
* `--include-global-config`
Include global configuration, that is not specific to any repository.

View file

@ -742,6 +742,7 @@ Executable git-annex
Command.ExamineKey
Command.Expire
Command.Export
Command.FilterBranch
Command.Find
Command.FindRef
Command.Fix