refactor(config): turn format detection into a table and split init and the JS loader - #1213
Merged
Merged
Conversation
BryanFRD
enabled auto-merge (squash)
September 28, 2026 07:00
Contributor
There was a problem hiding this comment.
Checked each extraction against the code it replaces; all five preserve behaviour.
detect_versioned_files: row order matches the old push order, and the two multi-candidate rows reproduce the old preference (build.gradle.ktsbeforebuild.gradle,VERSIONbeforeVERSION.txt). The old gradle block guarded onbuild.gradle || build.gradle.ktsand then re-tested.kts;findover the candidates in preference order is the same function.check_group:continue→else ifis equivalent. A member duplicated inside its own group still reports only the duplicate error, and a member that also appears in an earlier group still reports the multi-group error on its first occurrence there.ensure_no_config_exists:chainkeeps the old order (allCONFIG_FORMATS, then ts, then js) andfindshort-circuits on the first hit, so the reported filename is unchanged.collect_packages: the empty-name branch inverted cleanly, including the "at least one package is required" re-prompt when the list is empty.loader_js: both runners moved verbatim. The tsx message keeps its old inner indentation, which is fine since\at end of line eats the following whitespace;run_ts_loaderstill drops the tempdir before propagating the error.
Nit, src/config/init.rs:42: prompt_format still carries the indented/unindented pair by hand, the one copy of the pattern question was introduced to remove:
fn prompt_format(indent: bool) -> String {
let text = question("Version file format [toml/json/xml/gradle/gomod/txt]", indent);
loop {
let input = prompt(&text, "toml");It also drops the local binding named question, which currently shadows the new function of that name in this file.
ferrflow Bot
added a commit
that referenced
this pull request
Sep 28, 2026
## [7.26.9] - 2026-09-28 ### Refactoring - refactor(git): let the semver walk ask place instead of a second resolver (#1214) - refactor(config): turn format detection into a table and split init and the JS loader (#1213) - refactor(git): walk tags once instead of three near-copies (#1212) - refactor(formats): share the member and tag walkers instead of copying them (#1211)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1209. Clears the five
rust:S3776findings insrc/config/.Config::auto_detectConfig::validate_groupsinit::collect_packageinit::initloader_js::load_js_ts_config"After" is from a local implementation of Sonar's rules that reproduces its figure on 27 of the 31 open findings and never undercounts; Sonar confirms on
main. No helper introduced here goes above 8.What changed
auto_detectwas nineif file exists, push this formatblocks. It is nowDETECTED_VERSION_FILES, a table of candidate filenames and their format, read in the same order, where a row with two candidates takes the first that exists. That is what the two special cases already did by hand:build.gradle.ktsoverbuild.gradle,VERSIONoverVERSION.txt.validate_groupskeeps its loop and hands each group tocheck_group. Thecontinueafter a duplicate became anelse if, which says the same thing: a member listed twice in its own group is not also reported as belonging to two groups.collect_packageasked four questions with the sameif monorepo { " X" } else { "X" }around each label and the sameif path == "." { file } else { "{path}/{file}" }around two defaults. Those arequestionandunder.initis its three steps named:ensure_no_config_exists(one chain over every config filename, same message, same order),collect_packages, then the write.load_js_ts_configcarried both runners inline. The tsx and node paths arerun_ts_loaderandrun_node_loader, moved as they were, error messages untouched, and the shared tail isparse_loader_output.Verified
auto_detecthas fifteen dedicated tests inconfig/tests.rs, including gradle.ktspreference,VERSIONpreference, several files at once and the no-file case;groups.rshas its own. The interactive prompts ininithave no test harness, so that part rests on the diff being a rename of repeated expressions.cargo test: 1098 + 1493.cargo clippy --all-targets -- -D warningsclean.