summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Git.hs
diff options
context:
space:
mode:
authorFélix Sipma2014-11-23 18:42:36 +0100
committerJoey Hess2014-11-23 14:39:01 -0400
commit226981cda4597f6564b9e31d826efc84a2ce61a5 (patch)
tree333c8aa4a8e2542da65f399f99031df31f29c0a6 /src/Propellor/Property/Git.hs
parente8a07b184014e307919be8921ee3029bae809048 (diff)
Git: bareRepo
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src/Propellor/Property/Git.hs')
-rw-r--r--src/Propellor/Property/Git.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs
index 8d49cbd0..a2bec5ef 100644
--- a/src/Propellor/Property/Git.hs
+++ b/src/Propellor/Property/Git.hs
@@ -94,3 +94,23 @@ cloned owner url dir mbranch = check originurl (property desc checkout)
isGitDir :: FilePath -> IO Bool
isGitDir dir = isNothing <$> catchMaybeIO (readProcess "git" ["rev-parse", "--resolve-git-dir", dir])
+
+data GitShared = Shared GroupName | SharedAll | NotShared
+
+bareRepo :: FilePath -> UserName -> GitShared -> Property
+bareRepo repo user gitshared = check (isRepo repo) $ propertyList ("git repo: " ++ repo) $
+ dirExists repo : case gitshared of
+ NotShared ->
+ [ ownerGroup repo user user
+ , userScriptProperty user ["git", "init", "--bare", "--shared=false", repo]
+ ]
+ SharedAll ->
+ [ ownerGroup repo user user
+ , userScriptProperty user ["git", "init", "--bare", "--shared=all", repo]
+ ]
+ Shared group' ->
+ [ ownerGroup repo user group'
+ , userScriptProperty user ["git", "init", "--bare", "--shared=group", repo]
+ ]
+ where
+ isRepo repo' = isNothing <$> catchMaybeIO (readProcess "git" ["rev-parse", "--resolve-git-dir", repo'])