1{- git config types 2 - 3 - Copyright 2012, 2017 Joey Hess <id@joeyh.name> 4 - 5 - Licensed under the GNU AGPL version 3 or higher. 6 -} 7 8{-# LANGUAGE OverloadedStrings #-} 9 10module Git.ConfigTypes where 11 12import Data.Char 13import qualified Data.ByteString.Char8 as S8 14 15import Common 16import Git 17import Git.Types 18import qualified Git.Config 19 20data SharedRepository = UnShared | GroupShared | AllShared | UmaskShared Int 21 deriving (Eq) 22 23getSharedRepository :: Repo -> SharedRepository 24getSharedRepository r = 25 case Git.Config.getMaybe "core.sharedrepository" r of 26 Just (ConfigValue v) -> case S8.map toLower v of 27 "1" -> GroupShared 28 "2" -> AllShared 29 "group" -> GroupShared 30 "true" -> GroupShared 31 "all" -> AllShared 32 "world" -> AllShared 33 "everybody" -> AllShared 34 _ -> maybe UnShared UmaskShared (readish (decodeBS v)) 35 Just NoConfigValue -> UnShared 36 Nothing -> UnShared 37 38data DenyCurrentBranch = UpdateInstead | RefusePush | WarnPush | IgnorePush 39 deriving (Eq) 40 41getDenyCurrentBranch :: Repo -> DenyCurrentBranch 42getDenyCurrentBranch r = 43 case Git.Config.getMaybe "receive.denycurrentbranch" r of 44 Just (ConfigValue v) -> case S8.map toLower v of 45 "updateinstead" -> UpdateInstead 46 "warn" -> WarnPush 47 "ignore" -> IgnorePush 48 _ -> RefusePush 49 Just NoConfigValue -> RefusePush 50 Nothing -> RefusePush 51