Skip to content

Commit

Permalink
only report top-level project config files in the default verbosity
Browse files Browse the repository at this point in the history
in verbose mode report imported files too
  • Loading branch information
ulysses4ever committed Nov 12, 2024
1 parent db8e6b4 commit 7f89bd0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Distribution.Solver.Types.ProjectConfigPath

-- * Checks and Normalization
, isCyclicConfigPath
, isTopLevelConfigPath
, canonicalizeConfigPath
) where

Expand Down Expand Up @@ -138,6 +139,11 @@ nullProjectConfigPath = ProjectConfigPath $ "unused" :| []
isCyclicConfigPath :: ProjectConfigPath -> Bool
isCyclicConfigPath (ProjectConfigPath p) = length p /= length (NE.nub p)

-- | Check if the project config path is top-level, meaning it was not included by
-- some other project config.
isTopLevelConfigPath :: ProjectConfigPath -> Bool
isTopLevelConfigPath (ProjectConfigPath p) = NE.length p == 1

-- | Prepends the path of the importee to the importer path.
consProjectConfigPath :: FilePath -> ProjectConfigPath -> ProjectConfigPath
consProjectConfigPath p ps = ProjectConfigPath (p <| coerce ps)
Expand Down
7 changes: 7 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Distribution.Client.ProjectConfig
, writeProjectLocalFreezeConfig
, writeProjectConfigFile
, commandLineFlagsToProjectConfig
, onlyTopLevelProvenance

-- * Packages within projects
, ProjectPackageLocation (..)
Expand Down Expand Up @@ -1753,3 +1754,9 @@ checkBadPerPackageCompilerPaths compilerPrograms packagesConfig =
] of
[] -> return ()
ps -> throwIO (BadPerPackageCompilerPaths ps)

-- | Filter out non-top-level project configs
onlyTopLevelProvenance :: Set ProjectConfigProvenance -> Set ProjectConfigProvenance
onlyTopLevelProvenance = Set.filter $ \case
Implicit -> False
Explicit ps -> isTopLevelConfigPath ps
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ rebuildProjectConfig
notice (verboseStderr verbosity) . render . vcat $
text "Configuration is affected by the following files:"
: [ text "-" <+> docProjectConfigPath path
| Explicit path <- Set.toList $ projectConfigProvenance projectConfig
| Explicit path <- Set.toList . (if verbosity >= verbose then id else onlyTopLevelProvenance) $ projectConfigProvenance projectConfig
]

return (projectConfig <> cliConfig, localPackages)
Expand Down

0 comments on commit 7f89bd0

Please sign in to comment.