-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(settings): distinguish unset known settings from unknown ones #9818
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ assert_contains "mise settings -T" "all_compile = true" | |
| mise settings unset all_compile | ||
| assert "mise settings get all_compile" "false" | ||
| assert_fail "mise settings get abcdefg" "mise ERROR Unknown setting: abcdefg" | ||
| assert_fail "mise settings get python.compile" "mise ERROR Setting [python.compile] is not set" | ||
| assert_fail "mise settings get cargo.registry_name" "mise ERROR Setting [cargo.registry_name] is not set" | ||
|
Comment on lines
15
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fully verify that the logic correctly distinguishes between unset known settings and actual typos (unknown settings), it is recommended to add a test case where a key has a valid prefix but an invalid leaf name (e.g., |
||
| assert "mise settings all_compile" "false" | ||
| assert "mise settings all_compile=1" | ||
| assert "mise settings all_compile" "true" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||
| use crate::config; | ||||||||||||||||||
| use crate::config::Settings; | ||||||||||||||||||
| use crate::config::settings::SETTINGS_META; | ||||||||||||||||||
| use eyre::bail; | ||||||||||||||||||
|
|
||||||||||||||||||
| /// Show a current setting | ||||||||||||||||||
|
|
@@ -37,6 +38,8 @@ impl SettingsGet { | |||||||||||||||||
| if let Some(v) = value.as_table().and_then(|t| t.get(k.0)) { | ||||||||||||||||||
| key = k.1; | ||||||||||||||||||
| value = v.clone() | ||||||||||||||||||
| } else if SETTINGS_META.contains_key(self.setting.as_str()) { | ||||||||||||||||||
| bail!("Setting [{}] is not set", self.setting); | ||||||||||||||||||
| } else { | ||||||||||||||||||
| bail!("Unknown setting: {}", self.setting); | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current check only identifies leaf settings as 'known'. Organizational groups (e.g., Additionally, the error messages use different formatting styles (brackets vs. no brackets, and different phrasing). It is better to use a consistent style for both types of errors. Using brackets for the key is consistent with other error messages in the codebase.
Suggested change
|
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the error message for unknown settings is updated to include brackets for consistency, this test case should be updated to match the new output.