Skip to content

Duplicate project import as a warning only #10933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Collaborator

Pretty much the same as #9933 but gives a warning instead of an error when duplicate imports that are not cyclical are detected. I did this work in Oct 2024 but didn't raise a pull request for it then.

@philderbeast philderbeast force-pushed the fix/y-fork-project-import-warning-only branch from 16a11bd to 95ec86a Compare April 21, 2025 15:41
Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

-- NOTE: Reverse the warnings so they are in line number order.
<&> \case ProjectParseOk ws x -> ProjectParseOk (reverse ws) x; x -> x
parseProject rootPath cacheDir httpTransport verbosity configToParse = do
let (dir, projectFileName) = splitFileName rootPath
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be preferable to not change layout/identation without a real need, I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strive for minimal diffs. In this situation, I was rebasing something older and it made the merge conflict resolution easier this way.

https://github.com/haskell/cabal/blame/51e1817dec9980d0d204a051fc3c4dc981c3d027/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs#L259-L266

https://github.com/haskell/cabal/blame/54d364df92b654ce712f0fe277ed709e710d8bf4/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs#L246-L250

I actually prefer the way it was before the latest commit, with the = do on the same line rather than do by itself on its own line. This also has less indentation.

If you're OK with the way it is, then I'd like to keep it that way, the way it was, one commit before the last commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised that fourmolu doesn't always normalize.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it could have been I used a more recent version of fourmolu at some stage.

@philderbeast philderbeast force-pushed the fix/y-fork-project-import-warning-only branch from 95ec86a to f108389 Compare April 22, 2025 23:22
- Add Y-forking import test
- A test for detecting when the same config is imported via many different paths
- Error on duplicate imports
- Do the filtering in duplicateImportMsg
- Use duplicateImportMsg for cycles too
- Add haddocks to IORef parameter
- Add changelog entry
- Use ordNub instead of nub
- Use NubList
- Share implement of duplicate and cyclical messages
- Update expectation for non-cyclical duplicate import
- Only show a warning
- Add woops project with a time cost
- Use noticeDoc instead of warn
- Render duplicate imports
- Add Ord instance for Dupes, sort on dupesNormLocPath
- Fixups after rebase
- Satisfy hlint
- Remove -XMultiWayIf
- Remove mention of yops from the changelog
- Satisfy fix-whitespace
- Test with a time cost of duplicate imports
@philderbeast philderbeast force-pushed the fix/y-fork-project-import-warning-only branch from f108389 to 115fcd2 Compare April 27, 2025 00:14
@philderbeast philderbeast force-pushed the fix/y-fork-project-import-warning-only branch from c230d20 to b61e031 Compare April 27, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants