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

Preserve the comments of the "cli.toml" on changes #2002

Merged
merged 7 commits into from
Jan 3, 2025

Conversation

mamcx
Copy link
Contributor

@mamcx mamcx commented Nov 19, 2024

Description of Changes

We would like to preserve a user's manual edits, including comments, so now 'tolm_edit' is used for mutating the config file.

Closes #1798.

API and ABI breaking changes

Marked breaking because of the change of crate to parse and save. Is the low-level used by 'toml'.

Expected complexity level and risk

2:

Marked breaking because of the change of how to parse and save the file (that mutates instead of generating a fresh immutable view of the config) even if according to test there is none.

Testing

  • Write unit testing that simulates different edits.
  • Run 'standalone' and execute several 'cli' commands to see manually if the config was updated without issues.

@mamcx mamcx added abi-break A PR that makes an ABI breaking change release-1.0 labels Nov 19, 2024
@mamcx mamcx self-assigned this Nov 19, 2024
crates/cli/src/config.rs Outdated Show resolved Hide resolved
@mamcx mamcx force-pushed the mamcx/config-preserve-edits branch from 82ba41f to d69605d Compare December 2, 2024 16:53
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

left lots of nits, none of them critical

Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

Additional (manual) testing I would like to see done:

  • Run multiple CLI processes concurrently / in parallel, such that they race to mutate a shared config file. Demonstrate that this does not corrupt or clear the config file, and describe the specific behavior.
  • Manually create an ill-formed config file, run a CLI process that would mutate it, and demonstrate that the ill-formed file is not (further) corrupted or cleared. Describe the specific behavior.

crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
@mamcx
Copy link
Contributor Author

mamcx commented Jan 3, 2025

Additional (manual) testing I would like to see done:

  • Run multiple CLI processes concurrently / in parallel, such that they race to mutate a shared config file. Demonstrate that this does not corrupt or clear the config file, and describe the specific behavior.
  • Manually create an ill-formed config file, run a CLI process that would mutate it, and demonstrate that the ill-formed file is not (further) corrupted or cleared. Describe the specific behavior.

I added an automated test instead.

@mamcx mamcx force-pushed the mamcx/config-preserve-edits branch from 71d3830 to 82743f2 Compare January 3, 2025 16:32
@mamcx mamcx force-pushed the mamcx/config-preserve-edits branch from 82743f2 to 2b38e8a Compare January 3, 2025 16:37
Copy link
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

Thank you for addressing those comments!

Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

Looks great!

@mamcx mamcx added this pull request to the merge queue Jan 3, 2025
Merged via the queue into master with commit df58e84 Jan 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abi-break A PR that makes an ABI breaking change release-1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI - Preserve comments when mutating the config file
3 participants