summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2015-11-24 09:35:11 -0400
committerJoey Hess2015-11-24 09:35:11 -0400
commit43e97837d7757c77d5742d62fca727541bf1a435 (patch)
tree3417b880eaa2fe1c7568ef64afcfe297fdc4cca2
parenta94e9ff8b55c6d5cac2c3de074a84eead990891a (diff)
parentdd02725a9e6d802b52212cfd89c9815745fe0f02 (diff)
Merge branch 'joeyconfig'
-rw-r--r--debian/changelog2
-rw-r--r--src/Propellor/Property/Git.hs20
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"