skeleton of filter-branch command, with option parser
authorJoey Hess <joeyh@joeyh.name>
Fri, 14 May 2021 14:59:48 +0000 (10:59 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 14 May 2021 14:59:48 +0000 (10:59 -0400)
CmdLine/GitAnnex.hs
Command/FilterBranch.hs [new file with mode: 0644]
doc/git-annex-filter-branch.mdwn
git-annex.cabal

index ac2b9b8216510001f17b5b57f224acf456e7c0f7..fe400814839d403915749d3d08c5785c39d8eca9 100644 (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
diff --git a/Command/FilterBranch.hs b/Command/FilterBranch.hs
new file mode 100644 (file)
index 0000000..db5159b
--- /dev/null
@@ -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"
index 45659772877995ab57bd853d613acf4a07cb381c..adaf3886e7acbfd1fce5bda3c811b2ac0d3f95f4 100644 (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.
index a7ba9c46aafaf696c0921f5c9519ceac6efc3b30..f12da50c0d977f41771718a50b3d8154e453dd50 100644 (file)
@@ -742,6 +742,7 @@ Executable git-annex
     Command.ExamineKey
     Command.Expire
     Command.Export
+    Command.FilterBranch
     Command.Find
     Command.FindRef
     Command.Fix