From 226981cda4597f6564b9e31d826efc84a2ce61a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Sipma?= Date: Sun, 23 Nov 2014 18:42:36 +0100 Subject: [PATCH] Git: bareRepo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: FĂ©lix Sipma --- src/Propellor/Property/Git.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs index 8d49cbd..a2bec5e 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'])