Skip to content
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

Implement --mergetool mode #283

Merged
merged 1 commit into from
Mar 3, 2025
Merged

Implement --mergetool mode #283

merged 1 commit into from
Mar 3, 2025

Conversation

infinisil
Copy link
Member

@infinisil infinisil commented Feb 17, 2025

Inspired by @oxij's #277, but implemented in Haskell, therefore faster (less process spawning) and trivially integrated into the build and distribution.

Things done:

  • Test this (there's automated tests!)
  • Docs like in the original PR

This work is funded by Antithesis and Tweag

Copy link

github-actions bot commented Feb 17, 2025

Nixpkgs diff

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/formatting-team-meeting-2025-02-18/60511/1

@infinisil infinisil marked this pull request as ready for review February 21, 2025 19:29
@infinisil infinisil requested a review from a team February 21, 2025 19:29
@infinisil
Copy link
Member Author

This is now done, please review :)

main/Main.hs Outdated
mergeToolJob :: Nixfmt -> IO Result
mergeToolJob opts@Nixfmt{files = [base, local, remote, merged]} = runExceptT $ do
let formatter = toFormatter opts
joinEithers :: [Either String ()] -> Either String ()
Copy link
Member

Choose a reason for hiding this comment

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

Why Either String () and not Maybe String?

Copy link
Member Author

@infinisil infinisil Feb 24, 2025

Choose a reason for hiding this comment

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

It's the return type of formatTarget, I guess using the typealias Result would make in clearer. Edit: Done that

Makes resolving formatting-related conflicts easier.

Idea and docs are from @oxij's #277.
Code and tests are from @infinisil.

By implementing it in Haskell, it's faster (less process spawning)
and trivially integrated into build and distribution.

Co-Authored-By: Jan Malakhovski <oxij@oxij.org>
@infinisil infinisil merged commit 28fad74 into master Mar 3, 2025
2 checks passed
@infinisil infinisil deleted the mergetool-hs branch March 3, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants