From dc0f824c1bc4c9aac1045894983a434eb26196ab Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 7 Feb 2017 14:35:58 -0400 Subject: add SetupStage parameter to RemoteType.setup Most remotes have an idempotent setup that can be reused for enableremote, but in a few cases, it needs to tell which, and whether a UUID was provided to setup was used. This is groundwork for making initremote be able to provide a UUID. It should not change any behavior. Note that it would be nice to make the UUID always be provided to setup, and make setup not need to generate and return a UUID. What prevented this simplification is Remote.Git.gitSetup, which needs to reuse the UUID of the git remote when setting it up, and so has to return that UUID. This commit was sponsored by Thom May on Patreon. --- Types/Remote.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Types') diff --git a/Types/Remote.hs b/Types/Remote.hs index dd4c7d2e5..bd75840b3 100644 --- a/Types/Remote.hs +++ b/Types/Remote.hs @@ -14,6 +14,7 @@ module Types.Remote , RemoteConfig , RemoteTypeA(..) , RemoteA(..) + , SetupStage(..) , Availability(..) , Verification(..) , unVerified @@ -38,8 +39,12 @@ import Utility.SafeCommand import Utility.Url type RemoteConfigKey = String + type RemoteConfig = M.Map RemoteConfigKey String +data SetupStage = Init | Enable + deriving (Eq) + {- There are different types of remotes. -} data RemoteTypeA a = RemoteType { -- human visible type name @@ -49,8 +54,8 @@ data RemoteTypeA a = RemoteType { enumerate :: Bool -> a [Git.Repo], -- generates a remote of this type generate :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> a (Maybe (RemoteA a)), - -- initializes or changes a remote - setup :: Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> a (RemoteConfig, UUID) + -- initializes or enables a remote + setup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> a (RemoteConfig, UUID) } instance Eq (RemoteTypeA a) where -- cgit v1.2.3