Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_cli): correctly compute configuration #3176

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

ematipico
Copy link
Contributor

Summary

Fixes #3175

We were incorrectly computing a WorkspaceSettings, while now we should change/create a Configuration struct instead and then update the settings of the workspace.

This bug went undetected because we don't have tests that check that arguments passed via CLI are correctly applied.

Test Plan

I created two new tests, one that applies the generic configuration of the formatter and one that applies the configuration for the javascript language.

@netlify
Copy link

netlify bot commented Sep 7, 2022

Deploy Preview for rometools ready!

Name Link
🔨 Latest commit 26cb57b
🔍 Latest deploy log https://app.netlify.com/sites/rometools/deploys/6319a0c83b82850009b30798
😎 Deploy Preview https://deploy-preview-3176--rometools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ematipico ematipico temporarily deployed to netlify-playground September 7, 2022 13:24 Inactive
@ematipico ematipico requested a review from a team September 7, 2022 13:24
@ematipico ematipico temporarily deployed to netlify-playground September 7, 2022 13:27 Inactive
@github-actions
Copy link

github-actions bot commented Sep 7, 2022

@ematipico ematipico changed the title fix(rome_cli): incorrectly compute configuration fix(rome_cli): correctly compute configuration Sep 7, 2022
}
apply_format_settings_from_cli(&mut session, &mut workspace_settings)?;
let configuration = apply_format_settings_from_cli(&mut session, configuration)?;
session
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this change mean for concurrent usages of the deamon. Do the CLI argument change for all requests to the workspace?

Copy link
Contributor Author

@ematipico ematipico Sep 7, 2022

Choose a reason for hiding this comment

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

Not sure want you mean. We only update the settings once (request), then each format_file request (for example) reads those settings anytime they need.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but what if multiple clients are connected to the same daemon

# client 1
rome format --indent-style="tab" --use-server

#client 2
rome format --indent-style="space" --use-server

And both commands run at the same time. Which configuration would be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both clients have two different instances of Workspace, so their configuration won't mix up.

Copy link
Contributor

@leops leops left a comment

Choose a reason for hiding this comment

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

This looks good overall, can we just add an additional test that has both a configuration file and CLI arguments override to ensure the priority is handled correctly ?

@ematipico ematipico temporarily deployed to netlify-playground September 8, 2022 07:59 Inactive
@ematipico ematipico merged commit a556f11 into main Sep 8, 2022
@ematipico ematipico deleted the fix/fix-argument-not-picked branch September 8, 2022 08:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 rome format ignores command line options
3 participants