2017-02-17 18:04:43 +00:00
|
|
|
{- git config types
|
2012-04-21 18:06:36 +00:00
|
|
|
-
|
2023-04-26 17:25:29 +00:00
|
|
|
- Copyright 2012-2023 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
|
2023-04-26 17:25:29 +00:00
|
|
|
import Numeric
|
2019-11-27 20:54:11 +00:00
|
|
|
import qualified Data.ByteString.Char8 as S8
|
2023-04-26 21:03:16 +00:00
|
|
|
import System.PosixCompat.Types
|
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
|
|
|
|
|
2023-04-26 21:03:16 +00:00
|
|
|
data SharedRepository = UnShared | GroupShared | AllShared | UmaskShared FileMode
|
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
|
|
|
|
Just (ConfigValue v) -> case S8.map toLower v of
|
|
|
|
"1" -> GroupShared
|
|
|
|
"2" -> AllShared
|
|
|
|
"group" -> GroupShared
|
|
|
|
"true" -> GroupShared
|
|
|
|
"all" -> AllShared
|
|
|
|
"world" -> AllShared
|
|
|
|
"everybody" -> AllShared
|
2023-04-26 17:25:29 +00:00
|
|
|
_ -> maybe UnShared UmaskShared
|
|
|
|
(fmap fst $ headMaybe $ readOct $ decodeBS v)
|
2020-04-13 17:35:22 +00:00
|
|
|
Just NoConfigValue -> UnShared
|
|
|
|
Nothing -> UnShared
|
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
|
2020-04-13 17:35:22 +00:00
|
|
|
Just NoConfigValue -> RefusePush
|
2019-12-05 18:36:43 +00:00
|
|
|
Nothing -> RefusePush
|