Skip to content

Commit 4852b97

Browse files
committed
Minor package display improvements
Displayed package names (stdout, log directory names) now use a hyphen e.g. aeson-1.2.3, rather than reusing the default delimiter == e.g. aeson ==1.2.3.
1 parent ff436aa commit 4852b97

File tree

11 files changed

+33
-19
lines changed

11 files changed

+33
-19
lines changed

src/builder/CLC/Stackage/Builder/Process.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ buildProject env idx pkgs = do
115115
mconcat
116116
[ T.pack $ show idx,
117117
": ",
118-
T.intercalate ", " (Package.toTextInstalled <$> pkgsList)
118+
T.intercalate ", " (Package.toDisplayName <$> pkgsList)
119119
]
120120
pkgsList = NE.toList pkgs.unPackageGroup
121121
pkgsSet = Set.fromList pkgsList

src/parser/CLC/Stackage/Parser.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ printPackageList mOs = do
5757
-- | Retrieves the package list formatted to text.
5858
getPackageListByOsFmt :: Os -> IO [Text]
5959
getPackageListByOsFmt =
60-
(fmap . fmap) Package.toTextInstalled
60+
(fmap . fmap) Package.toDisplayName
6161
. getPackageListByOs Logging.mkDefaultLogger Nothing
6262

6363
-- | Helper in case we want to see what the package set for a given OS is.

src/parser/CLC/Stackage/Parser/API/CabalConfig.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ parseCabalConfigLine txt = do
8282
let s = case T.stripPrefix "constraints:" txt' of
8383
Nothing -> txt'
8484
Just rest -> T.stripStart rest
85-
Package.packageParser s
85+
Package.fromCabalConstraintsText s
8686
where
8787
txt' = T.stripStart txt

src/utils/CLC/Stackage/Utils/Package.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ module CLC.Stackage.Utils.Package
1212
toCabalDepText,
1313
toCabalConstraintsText,
1414
toDirName,
15-
toTextInstalled,
15+
toDisplayName,
1616

1717
-- * Version
1818
PackageVersion (..),
19-
20-
-- * Parsers
21-
packageParser,
2219
)
2320
where
2421

@@ -89,7 +86,16 @@ toCabalConstraintsText = (<> ",") . toTextInstalled
8986
-- representation of 'toText'. Used when naming an error directory for a
9087
-- package that fails.
9188
toDirName :: Package -> IO OsPath
92-
toDirName = Paths.encodeUtf . T.unpack . toTextInstalled
89+
toDirName = Paths.encodeUtf . T.unpack . toDisplayName
90+
91+
-- | Slightly nicer display name e.g. "mtl-installed", "aeson-1.2.3".
92+
toDisplayName :: Package -> Text
93+
toDisplayName (MkPackage name vers) = txt
94+
where
95+
txt = name <> "-" <> v
96+
v = case vers of
97+
PackageVersionText t -> t
98+
PackageVersionInstalled -> "installed"
9399

94100
-- | Text representation of the package respecting "installed" versions e.g.
95101
--

test/functional/goldens/testSmallBatch_posix.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output/cache.json
2-
[2020-05-31 12:00:00][Success] 3: cborg ==0.2.10.0, clock ==0.8.4
3-
[2020-05-31 12:00:00][Success] 2: mtl ==2.3.1, optics-core ==0.4.1.1
4-
[2020-05-31 12:00:00][Success] 1: profunctors ==5.6.2
2+
[2020-05-31 12:00:00][Success] 3: cborg-0.2.10.0, clock-0.8.4
3+
[2020-05-31 12:00:00][Success] 2: mtl-2.3.1, optics-core-0.4.1.1
4+
[2020-05-31 12:00:00][Success] 1: profunctors-5.6.2
55

66

77
- Successes: 5 (100%)

test/functional/goldens/testSmallBatch_windows.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output\cache.json
2-
[2020-05-31 12:00:00][Success] 3: cborg ==0.2.10.0, clock ==0.8.4
3-
[2020-05-31 12:00:00][Success] 2: mtl ==2.3.1, optics-core ==0.4.1.1
4-
[2020-05-31 12:00:00][Success] 1: profunctors ==5.6.2
2+
[2020-05-31 12:00:00][Success] 3: cborg-0.2.10.0, clock-0.8.4
3+
[2020-05-31 12:00:00][Success] 2: mtl-2.3.1, optics-core-0.4.1.1
4+
[2020-05-31 12:00:00][Success] 1: profunctors-5.6.2
55

66

77
- Successes: 5 (100%)

test/functional/goldens/testSmallSnapshotPath_posix.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output/cache.json
22
[2020-05-31 12:00:00][Warn] Only found 8 packages. Is that right?
3-
[2020-05-31 12:00:00][Success] 1: cborg ==0.2.10.0, clock ==0.8.4, mtl insta...
3+
[2020-05-31 12:00:00][Success] 1: cborg-0.2.10.0, clock-0.8.4, mtl-installed...
44

55

66
- Successes: 5 (100%)

test/functional/goldens/testSmallSnapshotPath_windows.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output\cache.json
22
[2020-05-31 12:00:00][Warn] Only found 8 packages. Is that right?
3-
[2020-05-31 12:00:00][Success] 1: cborg ==0.2.10.0, clock ==0.8.4, mtl insta...
3+
[2020-05-31 12:00:00][Success] 1: cborg-0.2.10.0, clock-0.8.4, mtl-installed...
44

55

66
- Successes: 5 (100%)

test/functional/goldens/testSmall_posix.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output/cache.json
2-
[2020-05-31 12:00:00][Success] 1: cborg ==0.2.10.0, clock ==0.8.4, mtl ==2.3...
2+
[2020-05-31 12:00:00][Success] 1: cborg-0.2.10.0, clock-0.8.4, mtl-2.3.1, op...
33

44

55
- Successes: 5 (100%)

test/functional/goldens/testSmall_windows.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[2020-05-31 12:00:00][Info] Cached results do not exist: output\cache.json
2-
[2020-05-31 12:00:00][Success] 1: cborg ==0.2.10.0, clock ==0.8.4, mtl ==2.3...
2+
[2020-05-31 12:00:00][Success] 1: cborg-0.2.10.0, clock-0.8.4, mtl-2.3.1, op...
33

44

55
- Successes: 5 (100%)

test/unit/Unit/CLC/Stackage/Utils/Package.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ tests =
1515
"CLC.Stackage.Utils.Package"
1616
[ testFromCabalConstraintsTextSuccesses,
1717
testToCabalDepText,
18-
testToCabalConstraintsText
18+
testToCabalConstraintsText,
19+
testToDisplayName
1920
]
2021

2122
testFromCabalConstraintsTextSuccesses :: TestTree
@@ -43,6 +44,13 @@ testToCabalConstraintsText = testCase desc $ do
4344
where
4445
desc = "toCabalConstraintsText"
4546

47+
testToDisplayName :: TestTree
48+
testToDisplayName = testCase desc $ do
49+
"aeson-2.0.1" @=? Package.toDisplayName e1
50+
"mtl-installed" @=? Package.toDisplayName e2
51+
where
52+
desc = "toDisplayName"
53+
4654
e1 :: Package
4755
e1 =
4856
MkPackage

0 commit comments

Comments
 (0)