summaryrefslogtreecommitdiff
path: root/Git/GCrypt.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-05 16:34:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-05 16:34:13 -0400
commitd9c43c7a931db6fe658644b52fd815a6019320d2 (patch)
treeced0c975269c0e2e62c57ec16c7292424869ad41 /Git/GCrypt.hs
parentd9b78f90a9ceafa810d82c46d4eb489aeab8820b (diff)
add getParticipantList
Note that it needs to look at global git config, since git-remote-gcrypt will see any setting there as a fallback.
Diffstat (limited to 'Git/GCrypt.hs')
-rw-r--r--Git/GCrypt.hs28
1 files changed, 24 insertions, 4 deletions
diff --git a/Git/GCrypt.hs b/Git/GCrypt.hs
index 5f2694806..e22bd74a2 100644
--- a/Git/GCrypt.hs
+++ b/Git/GCrypt.hs
@@ -12,7 +12,8 @@ module Git.GCrypt where
import Common
import Git.Types
import Git.Construct
-import Git.Config
+import qualified Git.Config as Config
+import Utility.Gpg
urlPrefix :: String
urlPrefix = "gcrypt::"
@@ -47,7 +48,26 @@ encryptedRepo baserepo = go
- which is stored in the repository (in encrypted form)
- and cached in a per-remote gcrypt-id configuration setting. -}
remoteRepoId :: Repo -> Repo -> Maybe String
-remoteRepoId baserepo remote = do
+remoteRepoId = getRemoteConfig "gcrypt-id"
+
+getRemoteConfig :: String -> Repo -> Repo -> Maybe String
+getRemoteConfig field baserepo remote = do
name <- remoteName remote
- let key = "remote." ++ name ++ ".gcrypt-id"
- getMaybe key baserepo
+ Config.getMaybe (remoteConfigKey field name) baserepo
+
+{- Gpg keys that the remote is encrypted for.
+ - If empty, gcrypt uses --default-recipient-self -}
+particiantList :: Maybe Repo -> Repo -> Repo -> KeyIds
+particiantList globalconfigrepo baserepo remote = KeyIds $ parse $ firstJust
+ [ getRemoteConfig "participants" baserepo remote
+ , Config.getMaybe defaultkey baserepo
+ , Config.getMaybe defaultkey =<< globalconfigrepo
+ ]
+ where
+ defaultkey = "gcrypt.participants"
+ parse (Just "simple") = []
+ parse (Just l) = words l
+ parse Nothing = []
+
+remoteConfigKey :: String -> String -> String
+remoteConfigKey key field = "remote." ++ field ++ "." ++ key