addcomputed inherits extra initremote parameters

This is limited because the remote config is a field/value map. So order
is not preserved, and when 2 parameters have the same field name, only
the last one will be passed.
This commit is contained in:
Joey Hess 2025-02-26 09:45:35 -04:00
parent a5b53fa98a
commit eed522a0f8
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 12 deletions

View file

@ -88,8 +88,8 @@ perform o r program = do
repopath <- fromRepo Git.repoPath
subdir <- liftIO $ relPathDirToFile repopath (literalOsPath ".")
let state = Remote.Compute.ComputeState
-- TODO add inherited initremote parameters
{ Remote.Compute.computeParams = computeParams o
{ Remote.Compute.computeParams = computeParams o ++
Remote.Compute.defaultComputeParams r
, Remote.Compute.computeInputs = mempty
, Remote.Compute.computeOutputs = mempty
, Remote.Compute.computeSubdir = subdir

View file

@ -17,6 +17,7 @@ module Remote.Compute (
getComputeProgram,
runComputeProgram,
ImmutableState(..),
defaultComputeParams,
) where
import Annex.Common
@ -127,6 +128,11 @@ computeConfigParser _ = return $ RemoteConfigParser
)
}
defaultComputeParams :: Remote -> [String]
defaultComputeParams = map mk . M.toList . getRemoteConfigPassedThrough . config
where
mk (f, v) = fromProposedAccepted f ++ '=' : v
newtype ComputeProgram = ComputeProgram String
deriving (Show)

View file

@ -33,7 +33,9 @@ Some examples of how this might look:
git-annex addcomputed --to=y -- compress foo --level=9
git-annex addcomputed --to=z -- clip foo 2:01-3:00 combine with bar to baz
Note that parameters that were passed to `git-annex initremote`
when setting up the compute special remote will be appended to the end of
the parameters provided to `git-annex addcomputed`.
# OPTIONS
@ -88,6 +90,8 @@ Some examples of how this might look:
[[git-annex-recompute]](1)
[[git-annex-initremote]](1)
# AUTHOR
Joey Hess <id@joeyh.name>

View file

@ -2,6 +2,10 @@ While other remotes store the contents of annexed files somewhere,
this special remote uses a program to compute the contents of annexed
files.
To add a file to a compute special remote, use the [[git-annex-addcomputed]]
command. Once a file has been added to a compute special remote, commands
like `git-annex get` will use it to compute the content of the file.
To enable an instance of this special remote:
# git-annex initremote myremote type=compute program=git-annex-compute-foo
@ -11,16 +15,11 @@ program to use to compute the contents of annexed files. It must start with
"git-annex-compute-". The program needs to be installed somewhere in the
`PATH`.
To add a file to a compute special remote, use the [[git-annex-addcomputed]]
command. Once a file has been added to a compute special remote, commands
like `git-annex get` will use it to compute the content of the file.
All other "field=value" parameters passed to `initremote` will be passed
to the program when running [[git-annex-addcomputed]]. Note that when the
program takes a dashed option, it can be provided after "--":
You can provide other parameters to `initremote`, in order to provide
default configuration values to use when adding files with
[[git-annex-addcomputed]]. To see a list of all the configuration values
supported by a given program, pass `--whatelse` to `initremote`:
# git-annex initremote myremote type=compute program=git-annex-compute-foo --whatelse
# git-annex initremote myremote type=compute program=git-annex-compute-foo -- --level=9
## compute programs