From 2ab096650fe8d6265293420492f42cceedbce9ac Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 23 Nov 2015 21:47:23 -0700 Subject: 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 (cherry picked from commit cf3b48217a78460758615b52849e2b717ec24de9) --- src/Propellor/Property/Git.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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") -- cgit v1.3-2-g0d8e From d845790bce5a2a4b11de63867fbdd5ecfcc47380 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:30:20 -0400 Subject: fix indent --- src/Propellor/Property/Git.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs index 2c3a60ba..64a3b4d3 100644 --- a/src/Propellor/Property/Git.hs +++ b/src/Propellor/Property/Git.hs @@ -119,17 +119,17 @@ bareRepo repo user gitshared = check (isRepo repo) $ propertyList ("git repo: " repoConfigured :: FilePath -> (String, String) -> Property NoInfo repo `repoConfigured` (key, value) = trivial $ userScriptProperty (User "root") - [ "cd " ++ repo - , "git config " ++ key ++ " " ++ value - ] + [ "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") + 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") -- cgit v1.3-2-g0d8e From 923e4e783aaf7edd4ba83c51ad4b3f078bf00698 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:34:18 -0400 Subject: changelog --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) 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 Wed, 11 Nov 2015 13:37:00 -0400 -- cgit v1.3-2-g0d8e From dd02725a9e6d802b52212cfd89c9815745fe0f02 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 09:34:27 -0400 Subject: refactor --- src/Propellor/Property/Git.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Propellor/Property/Git.hs b/src/Propellor/Property/Git.hs index 64a3b4d3..d9540994 100644 --- a/src/Propellor/Property/Git.hs +++ b/src/Propellor/Property/Git.hs @@ -130,6 +130,7 @@ repoAcceptsNonFFs :: FilePath -> RevertableProperty NoInfo repoAcceptsNonFFs repo = accepts refuses where accepts = repoConfigured repo ("receive.denyNonFastForwards", "false") - `describe` ("git repo " ++ repo ++ " accepts non-fast-forward pushes") + `describe` desc "accepts" refuses = repoConfigured repo ("receive.denyNonFastForwards", "true") - `describe` ("git repo " ++ repo ++ " refuses non-fast-forward pushes") + `describe` desc "rejects" + desc s = "git repo " ++ repo ++ " " ++ s ++ " non-fast-forward pushes" -- cgit v1.3-2-g0d8e