Skip to content

Commit 9a343d1

Browse files
authored
Merge pull request #11067 from haskell/dont-mention-builddir-in-default-config-t11050
cabal update: don't show comment with builddir in the default config
2 parents 3f3e209 + a49146a commit 9a343d1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

cabal-install/src/Distribution/Client/Config.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,16 @@ showConfigWithComments comment vals =
17821782
(fmap (field . savedConfigureFlags) mcomment)
17831783
((field . savedConfigureFlags) vals)
17841784

1785-
-- skip fields based on field name. currently only skips "remote-repo",
1786-
-- because that is rendered as a section. (see 'ppRemoteRepoSection'.)
1787-
skipSomeFields = filter ((/= "remote-repo") . fieldName)
1785+
-- Skip fields based on field name.
1786+
skipSomeFields =
1787+
filter
1788+
( ( `notElem`
1789+
[ "remote-repo" -- rendered as a section (see 'ppRemoteRepoSection')
1790+
, "builddir" -- no effect in config file (see Note [reading project configuration])
1791+
]
1792+
)
1793+
. fieldName
1794+
)
17881795

17891796
-- | Fields for the 'install-dirs' sections.
17901797
installDirsFields :: [FieldDescr (InstallDirs (Flag PathTemplate))]

cabal-install/tests/IntegrationTests2.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,6 @@ testConfigOptionComments = do
26752675
"-- username" `assertHasCommentLine` "username"
26762676
"-- password" `assertHasCommentLine` "password"
26772677
"-- password-command" `assertHasCommentLine` "password-command"
2678-
"-- builddir" `assertHasCommentLine` "builddir"
26792678

26802679
" -- hoogle" `assertHasCommentLine` "hoogle"
26812680
" -- html" `assertHasCommentLine` "html"

changelog.d/pr-11067

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
synopsis: `cabal update`: create default config without comment about `builddir`
2+
packages: cabal-install
3+
prs: #11067
4+
issues: #11050
5+
description: {
6+
When calling `cabal update` with an empty state (empty `CABAL_DIR` or new
7+
machine), cabal writes out a default config file with many fields
8+
commented out to show their defaults. This suggests that the user can
9+
uncomment the field and override the default. This is wrong for fields
10+
that aren't allowed in the config file like `builddir`. This patch
11+
avoids generating a comment with `builddir` in the default config.
12+
}

0 commit comments

Comments
 (0)