autoenable sameas remotes
This commit is contained in:
parent
ec778888d2
commit
debafcba2b
6 changed files with 44 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2013-2016 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2013-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
|
|
@ -11,7 +11,6 @@ import qualified Data.Map as M
|
|||
|
||||
import Command
|
||||
import Annex.SpecialRemote
|
||||
import Annex.SpecialRemote.Config
|
||||
import qualified Remote
|
||||
import qualified Logs.Remote
|
||||
import qualified Types.Remote as R
|
||||
|
|
|
@ -29,7 +29,7 @@ start :: [String] -> CommandStart
|
|||
start (oldname:newname:[]) = Annex.SpecialRemote.findExisting oldname >>= \case
|
||||
Just (u, cfg, mcu) -> Annex.SpecialRemote.findExisting newname >>= \case
|
||||
Just _ -> giveup $ "The name " ++ newname ++ " is already used by a special remote."
|
||||
Nothing -> go u cfg
|
||||
Nothing -> go u cfg mcu
|
||||
-- Support lookup by uuid or description as well as remote name,
|
||||
-- as a fallback when there is nothing with the name in the
|
||||
-- special remote log.
|
||||
|
@ -39,17 +39,17 @@ start (oldname:newname:[]) = Annex.SpecialRemote.findExisting oldname >>= \case
|
|||
m <- Logs.Remote.readRemoteLog
|
||||
case M.lookup u m of
|
||||
Nothing -> giveup "That is not a special remote."
|
||||
Just cfg -> go u cfg
|
||||
Just cfg -> go u cfg Nothing
|
||||
where
|
||||
go u cfg = starting "rename" (ActionItemOther Nothing) $
|
||||
perform u cfg newname
|
||||
go u cfg mcu = starting "rename" (ActionItemOther Nothing) $
|
||||
perform u cfg mcu newname
|
||||
start _ = giveup "Specify an old name (or uuid or description) and a new name."
|
||||
|
||||
perform :: UUID -> R.RemoteConfig -> String -> CommandPerform
|
||||
perform u cfg newname = do
|
||||
let namefield = case M.lookup sameasNameField cfg of
|
||||
Just _ -> sameasNameField
|
||||
Nothing -> nameField
|
||||
Logs.Remote.configSet u (M.insert namefield newname cfg)
|
||||
perform :: UUID -> R.RemoteConfig -> Maybe (Annex.SpecialRemote.ConfigFrom UUID) -> String -> CommandPerform
|
||||
perform u cfg mcu newname = do
|
||||
let (namefield, cu) = case mcu of
|
||||
Nothing -> (nameField, u)
|
||||
Just (Annex.SpecialRemote.ConfigFrom u') -> (sameasNameField, u')
|
||||
Logs.Remote.configSet cu (M.insert namefield newname cfg)
|
||||
|
||||
next $ return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue