2017-02-17 18:04:43 +00:00
|
|
|
{- git config types
|
2012-04-21 18:06:36 +00:00
|
|
|
-
|
2017-02-17 18:04:43 +00:00
|
|
|
- Copyright 2012, 2017 Joey Hess <id@joeyh.name>
|
2012-04-21 18:06:36 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2012-04-21 18:06:36 +00:00
|
|
|
-}
|
|
|
|
|
2019-11-27 20:54:11 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2017-02-17 18:04:43 +00:00
|
|
|
module Git.ConfigTypes where
|
2012-04-21 18:06:36 +00:00
|
|
|
|
|
|
|
import Data.Char
|
2019-11-27 20:54:11 +00:00
|
|
|
import qualified Data.ByteString.Char8 as S8
|
2012-04-21 18:06:36 +00:00
|
|
|
|
|
|
|
import Common
|
|
|
|
import Git
|
2019-12-05 18:36:43 +00:00
|
|
|
import Git.Types
|
2012-04-21 18:06:36 +00:00
|
|
|
import qualified Git.Config
|
|
|
|
|
|
|
|
data SharedRepository = UnShared | GroupShared | AllShared | UmaskShared Int
|
2017-02-17 18:04:43 +00:00
|
|
|
deriving (Eq)
|
2012-04-21 18:06:36 +00:00
|
|
|
|
|
|
|
getSharedRepository :: Repo -> SharedRepository
|
|
|
|
getSharedRepository r =
|
2019-12-05 18:36:43 +00:00
|
|
|
case Git.Config.getMaybe "core.sharedrepository" r of
|
|
|
|
Nothing -> UnShared
|
|
|
|
Just (ConfigValue v) -> case S8.map toLower v of
|
|
|
|
"1" -> GroupShared
|
|
|
|
"2" -> AllShared
|
|
|
|
"group" -> GroupShared
|
|
|
|
"true" -> GroupShared
|
|
|
|
"all" -> AllShared
|
|
|
|
"world" -> AllShared
|
|
|
|
"everybody" -> AllShared
|
|
|
|
_ -> maybe UnShared UmaskShared (readish (decodeBS' v))
|
2017-02-17 18:04:43 +00:00
|
|
|
|
|
|
|
data DenyCurrentBranch = UpdateInstead | RefusePush | WarnPush | IgnorePush
|
|
|
|
deriving (Eq)
|
|
|
|
|
|
|
|
getDenyCurrentBranch :: Repo -> DenyCurrentBranch
|
2019-12-05 18:36:43 +00:00
|
|
|
getDenyCurrentBranch r =
|
|
|
|
case Git.Config.getMaybe "receive.denycurrentbranch" r of
|
|
|
|
Just (ConfigValue v) -> case S8.map toLower v of
|
|
|
|
"updateinstead" -> UpdateInstead
|
|
|
|
"warn" -> WarnPush
|
|
|
|
"ignore" -> IgnorePush
|
|
|
|
_ -> RefusePush
|
|
|
|
Nothing -> RefusePush
|