diff options
| author | Sean Whitton <spwhitton@spwhitton.name> | 2015-11-23 21:47:23 -0700 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-11-24 09:29:32 -0400 |
| commit | 2ab096650fe8d6265293420492f42cceedbce9ac (patch) | |
| tree | dccd3299cbbc6e13a9772a7bd8e0733cb5eafc09 /src | |
| parent | ad37af7a5f6eb237fa6c75c1b583e911bfd22f9e (diff) | |
Git.repoConfigured and Git.repoAcceptsNonFFs props
The latter is useful when setting up Git hosting using the Git.bareRepo
property.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
(cherry picked from commit cf3b48217a78460758615b52849e2b717ec24de9)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Git.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs index 8937d21a..2c3a60ba 100644 --- a/src/Propellor/Property/Git.hs +++ b/src/Propellor/Property/Git.hs @@ -114,3 +114,22 @@ bareRepo repo user gitshared = check (isRepo repo) $ propertyList ("git repo: " ] where isRepo repo' = isNothing <$> catchMaybeIO (readProcess "git" ["rev-parse", "--resolve-git-dir", repo']) + +-- | Set a key value pair in a git repo's configuration. +repoConfigured :: FilePath -> (String, String) -> Property NoInfo +repo `repoConfigured` (key, value) = + trivial $ userScriptProperty (User "root") + [ "cd " ++ repo + , "git config " ++ key ++ " " ++ value + ] + `describe` ("git repo at " ++ repo + ++ " config setting " ++ key ++ " set to " ++ value) + +-- | Whether a repo accepts non-fast-forward pushes. +repoAcceptsNonFFs :: FilePath -> RevertableProperty NoInfo +repoAcceptsNonFFs repo = accepts <!> refuses + where + accepts = repoConfigured repo ("receive.denyNonFastForwards", "false") + `describe` ("git repo " ++ repo ++ " accepts non-fast-forward pushes") + refuses = repoConfigured repo ("receive.denyNonFastForwards", "true") + `describe` ("git repo " ++ repo ++ " refuses non-fast-forward pushes") |
