diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-11-24 09:35:11 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-11-24 09:35:11 -0400 |
| commit | 43e97837d7757c77d5742d62fca727541bf1a435 (patch) | |
| tree | 3417b880eaa2fe1c7568ef64afcfe297fdc4cca2 | |
| parent | a94e9ff8b55c6d5cac2c3de074a84eead990891a (diff) | |
| parent | dd02725a9e6d802b52212cfd89c9815745fe0f02 (diff) | |
Merge branch 'joeyconfig'
| -rw-r--r-- | debian/changelog | 2 | ||||
| -rw-r--r-- | src/Propellor/Property/Git.hs | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 84c3fc6f..b530c7b8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ propellor (2.14.0) UNRELEASED; urgency=medium Thanks, Félix Sipma. * DebianMirror: Add RsyncExtra to configuration. Thanks, Félix Sipma. + * Added Git.repoConfigured and Git.repoAcceptsNonFFs properties. + Thanks, Sean Whitton -- Joey Hess <id@joeyh.name> Wed, 11 Nov 2015 13:37:00 -0400 diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs index 8937d21a..d9540994 100644 --- a/src/Propellor/Property/Git.hs +++ b/src/Propellor/Property/Git.hs @@ -114,3 +114,23 @@ 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` desc "accepts" + refuses = repoConfigured repo ("receive.denyNonFastForwards", "true") + `describe` desc "rejects" + desc s = "git repo " ++ repo ++ " " ++ s ++ " non-fast-forward pushes" |
