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

Add safe config updating #7224

Merged
merged 42 commits into from
Dec 24, 2024
Merged

Add safe config updating #7224

merged 42 commits into from
Dec 24, 2024

Conversation

Efnilite
Copy link
Member

Description

Changes

  • Fixes New 'backups to keep' entry not generated for existing configs #7184
  • Reformats all classes to be more up to date with code standards
    • Any non-new method changes are for improving code readability, improving the position of the methods in the class or using pattern matching.
  • Deprecates the current method for config updating, replacing it with Config#updateNodes

About updateNodes
Config#updateNodes differs from the current behaviour of Config#setValues as it does not touch any nodes in the existing config ("the old config") that are also present in the config provided with Skript ("the new config"). This ensures safety for critical sections like the databases section.

First, the difference between the nodes of the new and old config is found. These nodes that are missing from the old config will then be added to the old config at the index (the amount of nodes prior to the current one) at which they were found in the new config.

Testing
From my testing, this only seems to break when the old config is made invalid by de-indenting one of the entry nodes. This means the path of the following nodes are all different until the start of the next section (at the same indentation as the currently de-indented entry node, not any children). As a node's path is used to determine whether it is missing from the config, this will cause these following nodes to de-indent as well, deleting the current section head. This seems to be fixed by adding a check for whether the parsed config is valid, by using SectionNode#isValid.

Limitations
Currently, outdated comments are not deleted and I'm not sure whether we want to support keeping user-added comments present. Should this be added?

Removed
My sanity


Target Minecraft Versions: any
Requirements: none
Related Issues: #7184

@Efnilite Efnilite added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: high Issues with potentially high impact that could be harmful to users. needs testing Needs testing to determine current status or issue validity, or for WIP feature pulls. 2.10 Targeting a 2.10.X version release labels Nov 21, 2024
@Efnilite Efnilite removed the priority: high Issues with potentially high impact that could be harmful to users. label Nov 22, 2024
Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

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

I don't want the node classes to be reformatted in this PR.

@Efnilite Efnilite changed the title Add safe config updating, update config classes Add safe config updating Nov 28, 2024
Copy link
Member

@sovdeeth sovdeeth 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 overall but just want some testing assurances

src/main/java/ch/njol/skript/config/Config.java Outdated Show resolved Hide resolved
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

As sovde's comment mentioned, I would like to see some config-updating tests for this. Otherwise, it looks great!

src/main/java/ch/njol/skript/config/Config.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/config/Node.java Show resolved Hide resolved
src/main/java/ch/njol/skript/config/SectionNode.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/config/SectionNode.java Outdated Show resolved Hide resolved
@Efnilite Efnilite removed the needs testing Needs testing to determine current status or issue validity, or for WIP feature pulls. label Dec 20, 2024
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

Just about ready

src/main/java/ch/njol/skript/config/SectionNode.java Outdated Show resolved Hide resolved
src/test/resources/old-config.sk Outdated Show resolved Hide resolved
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

awesome!!

@Efnilite Efnilite added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Dec 20, 2024
@Moderocky Moderocky merged commit 93e5ac9 into dev/feature Dec 24, 2024
6 checks passed
@Efnilite Efnilite deleted the feature/safe-config-update branch January 1, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.10 Targeting a 2.10.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants