summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--src/Propellor/Property/Versioned.hs24
2 files changed, 24 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index 986dfd75..7ad30b40 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+propellor (4.4.1) UNRELEASED; urgency=medium
+
+ * Generate a better description for versioned properties.
+
+ -- Joey Hess <id@joeyh.name> Mon, 17 Jul 2017 16:51:11 -0400
+
propellor (4.4.0) unstable; urgency=medium
* Propellor.Property.Timezone: New module, contributed by Sean Whitton.
diff --git a/src/Propellor/Property/Versioned.hs b/src/Propellor/Property/Versioned.hs
index 58d3e8d5..87673c64 100644
--- a/src/Propellor/Property/Versioned.hs
+++ b/src/Propellor/Property/Versioned.hs
@@ -55,6 +55,9 @@
module Propellor.Property.Versioned (Versioned, version, (-->), (<|>)) where
import Propellor
+import Propellor.Types.Core
+
+import Data.List
-- | Something that has multiple versions of type `v`.
type Versioned v t = VersionedBy v -> t
@@ -89,12 +92,21 @@ processVerSpec
=> v
-> VerSpec v metatypes
-> RevertableProperty metatypes metatypes
-processVerSpec v (Base (c, p))
- | c v = p
- | otherwise = revert p
-processVerSpec v (More (c, p) vs)
- | c v = processVerSpec v vs `before` p
- | otherwise = revert p `before` processVerSpec v vs
+processVerSpec v s = combinedp s
+ `describe` intercalate " and " (combineddesc s [])
+ where
+ combinedp (Base (c, p))
+ | c v = p
+ | otherwise = revert p
+ combinedp (More (c, p) vs)
+ | c v = combinedp vs `before` p
+ | otherwise = revert p `before` combinedp vs
+ combineddesc (Base (c, p)) l
+ | c v = getDesc p : l
+ | otherwise = getDesc (revert p) : l
+ combineddesc (More (c, p) vs) l
+ | c v = getDesc p : combineddesc vs l
+ | otherwise = getDesc (revert p) : combineddesc vs l
-- | Specify a function that checks the version, and what
-- `RevertableProperty` to use if the version matches.