Skip to content

Conversation

@nevans
Copy link
Collaborator

@nevansnevans commented Dec 17, 2025

Backports #544 to the v0.5-stable branch. From that PR:

Grouping defaults by version and putting them all together at the bottom has almost guaranteed merge conflicts whenever a feature branch is merged/rebased or a backport branch is cherry-picked.

At the cost of one final merge conflict per branch, this should significantly reduce future merge conflicts in the config file. It's also easier to match documentation with default values when they're right next to each other.

This handles that "one final merge conflict" for this branch.

This will be used to simplify the code in lib/net/imap/config.rb. In this first step, only a couple pieces are extracted: * `AttrVersionDefaults` stores the `Config.version_defaults` hash. The hash's `#default_proc` is defined there, too. * `AttrVersionDefaults.compile` only freezes that hash.
This refactoring decouples the assignment of versioned default values and the creation of `version_defaults` config objects. At first, `version_defaults` stores hashes for each version's updated defaults. At the end, the hashes are transformed into config objects by `Config::AttrVersionDefaults.compile!`.
This also causes Config[0.7r] through Config[1.0r] to be aliases (rather than clones) of each other.
This avoids usage of the private `Config#defaults_hash` method, relying instead on the public `#load_defaults` API.
At the cost of one big conflict now, this should significantly reduce future merge conflicts in the config file. It's also easier to match documentation with default values when they're right next to each other. This also assigns all of the original (`Config[0]`) defaults explicitly, and not only where they differ from Config.default.
Similar to the versioned defaults, this could be a source of conflicts when merging, rebasing, or cherry-picking feature and backport branches. Now that all of the attributes specify their defaults, the current version's default config can be compiled from that. The sanity-check at the end of `config.rb` has been removed. It was there to protect against bad merges. Now that `Config.default` is also compiled from the version defaults added to each attr_accessor, the tests in `test/net/imap/test_config.rb` are good enough.
@nevansnevans added the backport This issue or PR is for a stable release branch label Dec 17, 2025
@nevansnevans changed the title ♻️ Refactor Config.versioned_defaults to reduce merge conflcts (backport)♻️ Refactor Config.versioned_defaults to reduce merge conflcts (backport to 0.5)Dec 17, 2025
@nevansnevans changed the title ♻️ Refactor Config.versioned_defaults to reduce merge conflcts (backport to 0.5)♻️ Refactor Config.versioned_defaults to reduce merge conflicts (backport to 0.5)Dec 17, 2025
@nevansnevans merged commit 9b3208a into v0.5-stableDec 17, 2025
39 checks passed
@nevansnevans deleted the backport-0.5/config/defaults branch December 17, 2025 14:59
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backportThis issue or PR is for a stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@nevans