@@ -102,21 +102,6 @@ showMessages = go 0
102
102
(atLevel l $ formatRejections (map (showQPNPOpt qpn) (reverse is)) ++ showFR c fr)
103
103
(go l ms)
104
104
105
- formatRejections :: [String ] -> String
106
- formatRejections [x] = " rejecting: " ++ x
107
- formatRejections xs = " rejecting: " ++ case L. nub prefixes of
108
- [prefix] -> prefix ++ " ; " ++ L. intercalate " , " versions
109
- _ -> L. intercalate " , " xs
110
- where
111
- (prefixes, versions) = unzip
112
- [ maybe (x, " " ) (\ hyphen -> (take hyphen x, drop (hyphen + 1 ) x)) ix
113
- | x <- xs
114
- -- Package names may contain hypens but a hypen is also the separator
115
- -- between the package name and its version so find the last hyphen in
116
- -- the string.
117
- , let ix = listToMaybe (reverse $ L. elemIndices ' -' x)
118
- ]
119
-
120
105
-- Handle many subsequent skipped package instances.
121
106
goPSkip :: Int
122
107
-> QPN
@@ -138,6 +123,32 @@ showMessages = go 0
138
123
let s = show l
139
124
in Step (" [" ++ replicate (3 - length s) ' _' ++ s ++ " ] " ++ x) xs
140
125
126
+ -- | Format a list of package names and versions as a rejection message,
127
+ -- avoiding repetition of the package name.
128
+ -- >>> formatRejections ["foo-1.0.0", "foo-1.0.1", "foo-1.0.2"]
129
+ -- "rejecting: foo; 1.0.0, 1.0.1, 1.0.2"
130
+ -- >>> formatRejections ["foo-1.0.0"]
131
+ -- "rejecting: foo-1.0.0"
132
+ -- >>> formatRejections ["foo-1.0.0", "bar-1.0.0"]
133
+ -- "rejecting: foo-1.0.0, bar-1.0.0"
134
+ -- >>> formatRejections []
135
+ -- "unexpected rejection set"
136
+ formatRejections :: [String ] -> String
137
+ formatRejections [] = " unexpected rejection set"
138
+ formatRejections [x] = " rejecting: " ++ x
139
+ formatRejections xs = " rejecting: " ++ case L. nub prefixes of
140
+ [prefix] -> prefix ++ " ; " ++ L. intercalate " , " versions
141
+ _ -> L. intercalate " , " xs
142
+ where
143
+ (prefixes, versions) = unzip
144
+ [ maybe (x, " " ) (\ hyphen -> (take hyphen x, drop (hyphen + 1 ) x)) ix
145
+ | x <- xs
146
+ -- Package names may contain hypens but a hypen is also the separator
147
+ -- between the package name and its version so find the last hyphen in
148
+ -- the string.
149
+ , let ix = listToMaybe (reverse $ L. elemIndices ' -' x)
150
+ ]
151
+
141
152
-- | Display the set of 'Conflicts' for a skipped package version.
142
153
showConflicts :: Set CS. Conflict -> String
143
154
showConflicts conflicts =
0 commit comments