Skip to content

Implement --mergetool mode#283

Merged
infinisil merged 1 commit intomasterfrom
mergetool-hs
Mar 3, 2025
Merged

Implement --mergetool mode#283
infinisil merged 1 commit intomasterfrom
mergetool-hs

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

@github-actions
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 <[email protected]>
@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
@github-project-automation github-project-automation bot moved this from Todo to Done in Nix formatting Mar 3, 2025
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