initremote, enableremote: Added --with-url to enable using git-remote-annex
Also sets remote.name.fetch to a typical value, same as git remote add does.
This commit is contained in:
parent
7d61a99da3
commit
22bf23782f
7 changed files with 69 additions and 25 deletions
|
@ -3,6 +3,8 @@ git-annex (10.20240431) UNRELEASED; urgency=medium
|
||||||
* git-remote-annex: New program which allows pushing a git repo to a
|
* git-remote-annex: New program which allows pushing a git repo to a
|
||||||
git-annex special remote, and cloning from a special remote.
|
git-annex special remote, and cloning from a special remote.
|
||||||
(Based on Michael Hanke's git-remote-datalad-annex.)
|
(Based on Michael Hanke's git-remote-datalad-annex.)
|
||||||
|
* initremote, enableremote: Added --with-url to enable using
|
||||||
|
git-remote-annex.
|
||||||
* fsck: Fix recent reversion that made it say it was checksumming files
|
* fsck: Fix recent reversion that made it say it was checksumming files
|
||||||
whose content is not present.
|
whose content is not present.
|
||||||
* Avoid the --fast option preventing checksumming in some cases it
|
* Avoid the --fast option preventing checksumming in some cases it
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex command
|
{- git-annex command
|
||||||
-
|
-
|
||||||
- Copyright 2013-2023 Joey Hess <id@joeyh.name>
|
- Copyright 2013-2024 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -19,6 +19,7 @@ import qualified Annex.SpecialRemote as SpecialRemote
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
import qualified Remote.Git
|
import qualified Remote.Git
|
||||||
|
import qualified Command.InitRemote
|
||||||
import Logs.UUID
|
import Logs.UUID
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Config
|
import Config
|
||||||
|
@ -34,18 +35,32 @@ cmd = withAnnexOptions [jsonOptions] $
|
||||||
command "enableremote" SectionSetup
|
command "enableremote" SectionSetup
|
||||||
"enables git-annex to use a remote"
|
"enables git-annex to use a remote"
|
||||||
(paramPair paramName $ paramOptional $ paramRepeating paramParamValue)
|
(paramPair paramName $ paramOptional $ paramRepeating paramParamValue)
|
||||||
(withParams seek)
|
(seek <$$> optParser)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
data EnableRemoteOptions = EnableRemoteOptions
|
||||||
seek = withWords (commandAction . start)
|
{ cmdparams :: CmdParams
|
||||||
|
, withUrl :: Bool
|
||||||
|
}
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
optParser :: CmdParamsDesc -> Parser EnableRemoteOptions
|
||||||
start [] = unknownNameError "Specify the remote to enable."
|
optParser desc = EnableRemoteOptions
|
||||||
start (name:rest) = go =<< filter matchingname <$> Annex.getGitRemotes
|
<$> cmdParams desc
|
||||||
|
<*> switch
|
||||||
|
( long "with-url"
|
||||||
|
<> short 'u'
|
||||||
|
<> help "configure remote with an annex:: url"
|
||||||
|
)
|
||||||
|
|
||||||
|
seek :: EnableRemoteOptions -> CommandSeek
|
||||||
|
seek o = withWords (commandAction . (start o)) (cmdparams o)
|
||||||
|
|
||||||
|
start :: EnableRemoteOptions -> [String] -> CommandStart
|
||||||
|
start _ [] = unknownNameError "Specify the remote to enable."
|
||||||
|
start o (name:rest) = go =<< filter matchingname <$> Annex.getGitRemotes
|
||||||
where
|
where
|
||||||
matchingname r = Git.remoteName r == Just name
|
matchingname r = Git.remoteName r == Just name
|
||||||
go [] = deadLast name $
|
go [] = deadLast name $
|
||||||
startSpecialRemote name (Logs.Remote.keyValToConfig Proposed rest)
|
startSpecialRemote o name (Logs.Remote.keyValToConfig Proposed rest)
|
||||||
go (r:_)
|
go (r:_)
|
||||||
| not (null rest) = go []
|
| not (null rest) = go []
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
|
@ -69,8 +84,8 @@ startNormalRemote name r = starting "enableremote (normal)" ai si $ do
|
||||||
ai = ActionItemOther (Just (UnquotedString name))
|
ai = ActionItemOther (Just (UnquotedString name))
|
||||||
si = SeekInput [name]
|
si = SeekInput [name]
|
||||||
|
|
||||||
startSpecialRemote :: Git.RemoteName -> Remote.RemoteConfig -> [(UUID, Remote.RemoteConfig, Maybe (SpecialRemote.ConfigFrom UUID))] -> CommandStart
|
startSpecialRemote :: EnableRemoteOptions -> Git.RemoteName -> Remote.RemoteConfig -> [(UUID, Remote.RemoteConfig, Maybe (SpecialRemote.ConfigFrom UUID))] -> CommandStart
|
||||||
startSpecialRemote = startSpecialRemote' "enableremote" performSpecialRemote
|
startSpecialRemote o = startSpecialRemote' "enableremote" (performSpecialRemote o)
|
||||||
|
|
||||||
type PerformSpecialRemote = RemoteType -> UUID -> R.RemoteConfig -> R.RemoteConfig -> RemoteGitConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandPerform
|
type PerformSpecialRemote = RemoteType -> UUID -> R.RemoteConfig -> R.RemoteConfig -> RemoteGitConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandPerform
|
||||||
|
|
||||||
|
@ -97,8 +112,8 @@ startSpecialRemote' cname perform name config ((u, c, mcu):[]) =
|
||||||
startSpecialRemote' _ _ _ _ _ =
|
startSpecialRemote' _ _ _ _ _ =
|
||||||
giveup "Multiple remotes have that name. Either use git-annex renameremote to rename them, or specify the uuid of the remote."
|
giveup "Multiple remotes have that name. Either use git-annex renameremote to rename them, or specify the uuid of the remote."
|
||||||
|
|
||||||
performSpecialRemote :: PerformSpecialRemote
|
performSpecialRemote :: EnableRemoteOptions -> PerformSpecialRemote
|
||||||
performSpecialRemote t u oldc c gc mcu = do
|
performSpecialRemote o t u oldc c gc mcu = do
|
||||||
-- Avoid enabling a special remote if there is another remote
|
-- Avoid enabling a special remote if there is another remote
|
||||||
-- with the same name.
|
-- with the same name.
|
||||||
case SpecialRemote.lookupName c of
|
case SpecialRemote.lookupName c of
|
||||||
|
@ -110,10 +125,10 @@ performSpecialRemote t u oldc c gc mcu = do
|
||||||
giveup $ "Not overwriting currently configured git remote named \"" ++ name ++ "\""
|
giveup $ "Not overwriting currently configured git remote named \"" ++ name ++ "\""
|
||||||
_ -> noop
|
_ -> noop
|
||||||
(c', u') <- R.setup t (R.Enable oldc) (Just u) Nothing c gc
|
(c', u') <- R.setup t (R.Enable oldc) (Just u) Nothing c gc
|
||||||
next $ cleanupSpecialRemote t u' c' mcu
|
next $ cleanupSpecialRemote o t u' c' mcu
|
||||||
|
|
||||||
cleanupSpecialRemote :: RemoteType -> UUID -> R.RemoteConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandCleanup
|
cleanupSpecialRemote :: EnableRemoteOptions -> RemoteType -> UUID -> R.RemoteConfig -> Maybe (SpecialRemote.ConfigFrom UUID) -> CommandCleanup
|
||||||
cleanupSpecialRemote t u c mcu = do
|
cleanupSpecialRemote o t u c mcu = do
|
||||||
case mcu of
|
case mcu of
|
||||||
Nothing -> Logs.Remote.configSet u c
|
Nothing -> Logs.Remote.configSet u c
|
||||||
Just (SpecialRemote.ConfigFrom cu) -> do
|
Just (SpecialRemote.ConfigFrom cu) -> do
|
||||||
|
@ -124,7 +139,9 @@ cleanupSpecialRemote t u c mcu = do
|
||||||
Just r -> do
|
Just r -> do
|
||||||
repo <- R.getRepo r
|
repo <- R.getRepo r
|
||||||
setRemoteIgnore repo False
|
setRemoteIgnore repo False
|
||||||
unless (Remote.gitSyncableRemoteType t) $
|
when (withUrl o) $
|
||||||
|
Command.InitRemote.setAnnexUrl c
|
||||||
|
unless (Remote.gitSyncableRemoteType t || withUrl o) $
|
||||||
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
|
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex command
|
{- git-annex command
|
||||||
-
|
-
|
||||||
- Copyright 2011-2023 Joey Hess <id@joeyh.name>
|
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -21,6 +21,7 @@ import Types.GitConfig
|
||||||
import Types.ProposedAccepted
|
import Types.ProposedAccepted
|
||||||
import Config
|
import Config
|
||||||
import Git.Config
|
import Git.Config
|
||||||
|
import Git.Types
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
@ -35,6 +36,7 @@ cmd = withAnnexOptions [jsonOptions] $
|
||||||
data InitRemoteOptions = InitRemoteOptions
|
data InitRemoteOptions = InitRemoteOptions
|
||||||
{ cmdparams :: CmdParams
|
{ cmdparams :: CmdParams
|
||||||
, sameas :: Maybe (DeferredParse UUID)
|
, sameas :: Maybe (DeferredParse UUID)
|
||||||
|
, withUrl :: Bool
|
||||||
, whatElse :: Bool
|
, whatElse :: Bool
|
||||||
, privateRemote :: Bool
|
, privateRemote :: Bool
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,11 @@ optParser :: CmdParamsDesc -> Parser InitRemoteOptions
|
||||||
optParser desc = InitRemoteOptions
|
optParser desc = InitRemoteOptions
|
||||||
<$> cmdParams desc
|
<$> cmdParams desc
|
||||||
<*> optional parseSameasOption
|
<*> optional parseSameasOption
|
||||||
|
<*> switch
|
||||||
|
( long "with-url"
|
||||||
|
<> short 'u'
|
||||||
|
<> help "configure remote with an annex:: url"
|
||||||
|
)
|
||||||
<*> switch
|
<*> switch
|
||||||
( long "whatelse"
|
( long "whatelse"
|
||||||
<> short 'w'
|
<> short 'w'
|
||||||
|
@ -125,10 +132,22 @@ cleanup t u name c o = do
|
||||||
cu <- liftIO genUUID
|
cu <- liftIO genUUID
|
||||||
setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu)
|
setConfig (remoteAnnexConfig c "config-uuid") (fromUUID cu)
|
||||||
Logs.Remote.configSet cu c
|
Logs.Remote.configSet cu c
|
||||||
unless (Remote.gitSyncableRemoteType t) $
|
when (withUrl o) $
|
||||||
|
setAnnexUrl c
|
||||||
|
unless (Remote.gitSyncableRemoteType t || withUrl o) $
|
||||||
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
|
setConfig (remoteConfig c "skipFetchAll") (boolConfig True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
setAnnexUrl :: R.RemoteConfig -> Annex ()
|
||||||
|
setAnnexUrl c =
|
||||||
|
getConfigMaybe (remoteConfig c "url") >>= \case
|
||||||
|
Just (ConfigValue _) -> noop
|
||||||
|
_ -> do
|
||||||
|
setConfig (remoteConfig c "url") "annex::"
|
||||||
|
setConfig (remoteConfig c "fetch") $
|
||||||
|
"+refs/heads/*:refs/remotes/" ++
|
||||||
|
getRemoteName c ++ "/*"
|
||||||
|
|
||||||
describeOtherParamsFor :: RemoteConfig -> RemoteType -> CommandPerform
|
describeOtherParamsFor :: RemoteConfig -> RemoteType -> CommandPerform
|
||||||
describeOtherParamsFor c t = do
|
describeOtherParamsFor c t = do
|
||||||
cp <- R.configParser t c
|
cp <- R.configParser t c
|
||||||
|
|
|
@ -59,6 +59,11 @@ has found didn't work before and gave up on using, setting
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
* `--with-url`
|
||||||
|
|
||||||
|
This configures the remote with an "annex::" url, which allows
|
||||||
|
git to push to and pull from it, using [[git-remote-annex]].
|
||||||
|
|
||||||
* `--json`
|
* `--json`
|
||||||
|
|
||||||
Enable JSON output. This is intended to be parsed by programs that use
|
Enable JSON output. This is intended to be parsed by programs that use
|
||||||
|
|
|
@ -38,6 +38,11 @@ want to use `git annex renameremote`.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
* `--with-url`
|
||||||
|
|
||||||
|
This configures the remote with an "annex::" url, which allows
|
||||||
|
git to push to and pull from it, using [[git-remote-annex]].
|
||||||
|
|
||||||
* `--whatelse` / `-w`
|
* `--whatelse` / `-w`
|
||||||
|
|
||||||
Describe additional configuration parameters that you could specify.
|
Describe additional configuration parameters that you could specify.
|
||||||
|
|
|
@ -28,8 +28,9 @@ shorter url of "annex::" is sufficient. For example:
|
||||||
git push foo master
|
git push foo master
|
||||||
|
|
||||||
Configuring the url like that is automatically done when cloning from a
|
Configuring the url like that is automatically done when cloning from a
|
||||||
special remote, but not by [[git-annex-initremote]](1) and
|
special remote. To make [[git-annex-initremote]](1) and
|
||||||
[[git-annex-enableremote]](1).
|
[[git-annex-enableremote]](1) configure the url, pass them the `--with-url`
|
||||||
|
option.
|
||||||
|
|
||||||
When a special remote needs some additional credentials to be provided,
|
When a special remote needs some additional credentials to be provided,
|
||||||
they are not included in the URL, and need to be provided when cloning from
|
they are not included in the URL, and need to be provided when cloning from
|
||||||
|
|
|
@ -26,11 +26,6 @@ This is implememented and working. Remaining todo list for it:
|
||||||
There are some difficulties to doing this, including that
|
There are some difficulties to doing this, including that
|
||||||
RemoteConfig can have hidden fields that should be omitted.
|
RemoteConfig can have hidden fields that should be omitted.
|
||||||
|
|
||||||
* initremote/enableremote could have an option that configures the url to a
|
|
||||||
special remote to a annex:: url. This would make it easier to use
|
|
||||||
git-remote-annex, since the user would not need to set up the url
|
|
||||||
themselves. (Also it would then avoid setting `skipFetchAll = true`)
|
|
||||||
|
|
||||||
* datalad-annex supports cloning from the web special remote,
|
* datalad-annex supports cloning from the web special remote,
|
||||||
using an url that contains the result of pushing to eg, a directory
|
using an url that contains the result of pushing to eg, a directory
|
||||||
special remote.
|
special remote.
|
||||||
|
|
Loading…
Reference in a new issue