aboutsummaryrefslogtreecommitdiff
path: root/Logs/Group.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-10 16:04:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-10 16:04:28 -0400
commit7053033f7708c2e432b3ad3e62356bd395932899 (patch)
tree2b0c617c4e9a4a2e42aee458ee1c4d3421b63d18 /Logs/Group.hs
parent7d6bea416ac6ef0abd900fdb2b941c79168cbb48 (diff)
add standard group selector to repo edit form
Diffstat (limited to 'Logs/Group.hs')
-rw-r--r--Logs/Group.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Logs/Group.hs b/Logs/Group.hs
index 09d431e63..a58eafe92 100644
--- a/Logs/Group.hs
+++ b/Logs/Group.hs
@@ -10,6 +10,7 @@ module Logs.Group (
groupSet,
lookupGroups,
groupMap,
+ getStandardGroup
) where
import qualified Data.Map as M
@@ -21,6 +22,7 @@ import qualified Annex.Branch
import qualified Annex
import Logs.UUIDBased
import Types.Group
+import Types.StandardGroups
{- Filename of group.log. -}
groupLog :: FilePath
@@ -64,3 +66,11 @@ makeGroupMap byuuid = GroupMap byuuid bygroup
bygroup = M.fromListWith S.union $
concat $ map explode $ M.toList byuuid
explode (u, s) = map (\g -> (g, S.singleton u)) (S.toList s)
+
+{- If a repository is in exactly one standard group, returns it. -}
+getStandardGroup :: UUID -> GroupMap -> Maybe StandardGroup
+getStandardGroup u m = maybe Nothing go $ u `M.lookup` groupsByUUID m
+ where
+ go s = case catMaybes $ map toStandardGroup $ S.toList s of
+ [g] -> Just g
+ _ -> Nothing