Skip to content

Fix regression in detecting project's root#1180

Merged
gpetiot merged 3 commits intoocaml-ppx:masterfrom
Julow:root_with_name
Dec 12, 2019
Merged

Fix regression in detecting project's root#1180
gpetiot merged 3 commits intoocaml-ppx:masterfrom
Julow:root_with_name

Conversation

@Julow
Copy link
Copy Markdown
Collaborator

@Julow Julow commented Dec 9, 2019

Fix #1139

The value of --name was used as the starting point when searching for .ocamlformat files.
This behavior has been removed in #1127 but this breaks editor integration.
The emacs plugin calls ocamlformat like that: ocamlformat --name src/my_file.ml /tmp/some_tmp_dir/some_tmp_file.ml.

This PR restore this behavior and add a test. Editors should probably use the --root option but it seems broken, any idea ?

@Julow Julow requested review from emillon, gpetiot and jberdine December 9, 2019 14:20
@facebook-github-bot
Copy link
Copy Markdown

Hi Julow! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@jberdine
Copy link
Copy Markdown
Collaborator

jberdine commented Dec 9, 2019 via email

@facebook-github-bot
Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@Julow
Copy link
Copy Markdown
Collaborator Author

Julow commented Dec 9, 2019

Independent of other considerations like editors, this itself seems like a bad idea. What is the motivation for this change?

This wasn't intentional. I just found out about this behavior today.
Now there is a test for it and a little bit of doc, so it shouldn't disappear again.

@emillon
Copy link
Copy Markdown
Collaborator

emillon commented Dec 9, 2019

Editors should probably use the --root option but it seems broken, any idea ?

I don't think so, they should either use project detection from ocamlformat or from dune build rules. Otherwise this means that it'll have to be implemented in editors, which doesn't sound great?

@Julow
Copy link
Copy Markdown
Collaborator Author

Julow commented Dec 9, 2019

I don't think so, they should either use project detection from ocamlformat or from dune build rules. Otherwise this means that it'll have to be implemented in editors, which doesn't sound great?

I agree. Editors shouldn't do that, they might not even know the root of the project.

Copy link
Copy Markdown
Collaborator

@gpetiot gpetiot left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@gpetiot
Copy link
Copy Markdown
Collaborator

gpetiot commented Dec 11, 2019

The tests look good to me, if you managed to reproduce the bug in emacs before the PR and it is fixed with this PR we can merge.

@Julow Julow added the no changelog set this to bypass the CI check for changelog entries label Dec 12, 2019
@Julow
Copy link
Copy Markdown
Collaborator Author

Julow commented Dec 12, 2019

I think no changelog entry is needed as this fix a regression that hasn't been released. The fix works for me but I don't have a complete emacs setup.

@gpetiot gpetiot merged commit f448ad3 into ocaml-ppx:master Dec 12, 2019
bogdan2412 pushed a commit to bogdan2412/ocamlformat that referenced this pull request Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog set this to bypass the CI check for changelog entries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: fatal errors are swallowed

5 participants