Repository navigation
fix: read snake_case keys from yek config files - #269
Open
amareshhebbar wants to merge 1 commit into
Open
amareshhebbar wants to merge 1 commit into
amareshhebbar wants to merge 1 commit into
Conversation
9 tasks done
This branch has not been deployed
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.
Fixes #268
Problem
The README's example
yek.yamluses snake_case keys (ignore_patterns,priority_rules,git_boost_max,max_size,output_templateand others).clap-config-filenames every config field in kebab-case, so those keys are silently dropped. #251 fixed this for the five boolean flags only.Change
YekConfig::apply_snake_case_config_keysruns right afterapply_config_bool_overrides. It reads the same config file and, for each setting whose snake_case key is present and whose kebab-case key is not, applies the value:ignore_patternsandunignore_patternsextend the list, the same as the kebab-case keys and the CLI.priority_rules,binary_extensions,git_boost_max,max_git_depthandcategory_weightsare set from the file.output_dir,output_nameandoutput_templateare filled only when still unset, so the CLI keeps precedence.max_sizeis taken from the file only when it still has the default10MB.The values go through the existing
validate(), so an invalid pattern in a snake_case key fails the same way as in a kebab-case key. If a file sets both spellings, the kebab-case key wins, so existing configs behave exactly as before. The README now says both spellings are accepted.One limit: if someone passes
--max-size 10MBon the CLI and also setsmax_sizein snake_case in the file, the file value wins, because the CLI value equals the default. The kebab-case key does not have this limit.Tests
New tests in
tests/main_test.rsrun the binary:test_main_with_snake_case_yaml_config: snake_caseignore_patterns,priority_rulesandoutput_templateinyek.yamlare applied.test_main_with_snake_case_toml_config: snake_caseignore_patternsinyek.tomlis applied.test_main_kebab_case_config_key_wins_over_snake_case: with both spellings, the kebab-case value is used.test_main_cli_ignore_patterns_extend_snake_case_config: CLI and config patterns both apply.Without the change, the YAML, TOML and CLI tests fail. The kebab-case test passes before and after, as a guard.
Verification
All pass on Fedora.
I used an AI assistant to help trace the bug and draft the change. I reproduced the bug myself, read the change, and ran the full suite locally.