Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(config): remove vestigial OverridableConfig type (#2093)
Maximilian Roosc6dd38a0752b
diff --git a/src/config/mod.rs b/src/config/mod.rsindex 329301faf..3508ffc31 100644--- a/src/config/mod.rs+++ b/src/config/mod.rs@@ -117,8 +117,8 @@ pub use project::{pub(crate) use user::LoadError;pub use user::{CommitConfig, CommitGenerationConfig, CopyIgnoredConfig, ListConfig, MergeConfig,- OverridableConfig, ResolvedConfig, StageMode, StepConfig, SwitchConfig, SwitchPickerConfig,- UserConfig, UserProjectOverrides, config_path, default_config_path, default_system_config_path,+ ResolvedConfig, StageMode, StepConfig, SwitchConfig, SwitchPickerConfig, UserConfig,+ UserProjectOverrides, config_path, default_config_path, default_system_config_path,find_unknown_keys as find_unknown_user_keys, set_config_path, system_config_path,valid_user_config_keys,};diff --git a/src/config/user/mod.rs b/src/config/user/mod.rsindex b9dfeeec0..3e2fc0119 100644--- a/src/config/user/mod.rs+++ b/src/config/user/mod.rs@@ -28,9 +28,8 @@ pub use path::{pub use resolved::ResolvedConfig;pub use schema::{find_unknown_keys, valid_user_config_keys};pub use sections::{- CommitConfig, CommitGenerationConfig, CopyIgnoredConfig, ListConfig, MergeConfig,- OverridableConfig, StageMode, StepConfig, SwitchConfig, SwitchPickerConfig,- UserProjectOverrides,+ CommitConfig, CommitGenerationConfig, CopyIgnoredConfig, ListConfig, MergeConfig, StageMode,+ StepConfig, SwitchConfig, SwitchPickerConfig, UserProjectOverrides,};/// Distinguishes *why* `UserConfig::load()` failed so callers can emitdiff --git a/src/config/user/schema.rs b/src/config/user/schema.rsindex 1b86ac82d..5c998830d 100644--- a/src/config/user/schema.rs+++ b/src/config/user/schema.rs@@ -8,7 +8,7 @@ use super::UserConfig;/// Returns all valid top-level keys in user config, derived from the JsonSchema.///-/// This includes keys from UserConfig, OverridableConfig (flattened), and HooksConfig (flattened).+/// This includes keys from UserConfig and HooksConfig (flattened)./// Public for use by the `WorktrunkConfig` trait implementation.pub fn valid_user_config_keys() -> Vec<String> {let schema = SchemaGenerator::default().into_root_schema_for::<UserConfig>();diff --git a/src/config/user/sections.rs b/src/config/user/sections.rsindex 0d09c5182..29ce7a4e5 100644--- a/src/config/user/sections.rs+++ b/src/config/user/sections.rs@@ -460,80 +460,6 @@ impl Merge for StepConfig {}}-/// Settings that can be set globally or per-project.-///-/// This is a merge-only type — not a serde target. Fields are inlined directly-/// into `UserConfig` and `UserProjectOverrides` for deserialization (avoiding-/// `#[serde(flatten)]` which causes toml to lose error locations). Use-/// `UserProjectOverrides::overridable_config()` to construct this for merging.-#[derive(Debug, Clone, PartialEq, Default)]-pub struct OverridableConfig {- pub hooks: HooksConfig,- pub worktree_path: Option<String>,- pub list: Option<ListConfig>,- pub commit: Option<CommitConfig>,- pub merge: Option<MergeConfig>,- pub switch: Option<SwitchConfig>,- pub step: Option<StepConfig>,- pub aliases: Option<BTreeMap<String, CommandConfig>>,-}--impl OverridableConfig {- /// Returns true if all settings are None/default.- ///- /// Includes hooks check for per-project configs where hooks are stored here.- pub fn is_empty(&self) -> bool {- self.hooks == HooksConfig::default()- && self.worktree_path.is_none()- && self.list.is_none()- && self.commit.is_none()- && self.merge.is_none()- && self.switch.is_none()- && self.step.is_none()- && self.aliases.is_none()- }-}--impl Merge for OverridableConfig {- fn merge_with(&self, other: &Self) -> Self {- use super::merge::merge_optional;-- Self {- hooks: self.hooks.merge_with(&other.hooks), // Append semantics- worktree_path: other- .worktree_path- .clone()- .or_else(|| self.worktree_path.clone()),- list: merge_optional(self.list.as_ref(), other.list.as_ref()),- commit: merge_optional(self.commit.as_ref(), other.commit.as_ref()),- merge: merge_optional(self.merge.as_ref(), other.merge.as_ref()),- switch: merge_optional(self.switch.as_ref(), other.switch.as_ref()),- step: merge_optional(self.step.as_ref(), other.step.as_ref()),- aliases: merge_alias_maps(&self.aliases, &other.aliases), // Append semantics- }- }-}--/// Merge two optional alias maps using append semantics.-///-/// Both base and other aliases run on name collision (base first, then other),-/// matching how `HooksConfig::merge_with` appends hooks.-fn merge_alias_maps(- base: &Option<BTreeMap<String, CommandConfig>>,- other: &Option<BTreeMap<String, CommandConfig>>,-) -> Option<BTreeMap<String, CommandConfig>> {- match (base, other) {- (None, None) => None,- (Some(b), None) => Some(b.clone()),- (None, Some(o)) => Some(o.clone()),- (Some(b), Some(o)) => {- let mut merged = b.clone();- crate::config::commands::append_aliases(&mut merged, o);- Some(merged)- }- }-}-/// Per-project overrides in the user's config file////// Stored under `[projects."project-id"]` in the user's config.@@ -595,71 +521,3 @@ pub struct UserProjectOverrides {#[serde(default, skip_serializing_if = "Option::is_none")]pub aliases: Option<BTreeMap<String, CommandConfig>>,}--impl UserProjectOverrides {- /// Returns true if all fields are empty/None (no settings configured).- ///- /// Approvals are stored in `approvals.toml`, so `approved_commands` is only- /// kept here for backward-compatible parsing and migration — not checked.- pub fn is_empty(&self) -> bool {- self.overridable_config().is_empty()- }-- /// Construct an `OverridableConfig` from this project's inlined fields.- pub fn overridable_config(&self) -> OverridableConfig {- OverridableConfig {- hooks: self.hooks.clone(),- worktree_path: self.worktree_path.clone(),- list: self.list.clone(),- commit: self.commit.clone(),- merge: self.merge.clone(),- switch: self.switch.clone(),- step: self.step.clone(),- aliases: self.aliases.clone(),- }- }-}--#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn test_merge_alias_maps_both_none() {- assert_eq!(merge_alias_maps(&None, &None), None);- }-- #[test]- fn test_merge_alias_maps_base_only() {- let base = BTreeMap::from([("a".into(), CommandConfig::single("1"))]);- let result = merge_alias_maps(&Some(base.clone()), &None);- assert_eq!(result, Some(base));- }-- #[test]- fn test_merge_alias_maps_other_only() {- let other = BTreeMap::from([("b".into(), CommandConfig::single("2"))]);- let result = merge_alias_maps(&None, &Some(other.clone()));- assert_eq!(result, Some(other));- }-- #[test]- fn test_merge_alias_maps_appends_on_collision() {- let base = BTreeMap::from([- ("a".into(), CommandConfig::single("1")),- ("shared".into(), CommandConfig::single("base-cmd")),- ]);- let other = BTreeMap::from([- ("b".into(), CommandConfig::single("2")),- ("shared".into(), CommandConfig::single("other-cmd")),- ]);- let result = merge_alias_maps(&Some(base), &Some(other)).unwrap();- assert_eq!(result["a"].commands().count(), 1);- assert_eq!(result["b"].commands().count(), 1);- // Collision: both commands are preserved (base first, then other)- let shared: Vec<_> = result["shared"].commands().collect();- assert_eq!(shared.len(), 2);- assert_eq!(shared[0].template, "base-cmd");- assert_eq!(shared[1].template, "other-cmd");- }-}diff --git a/src/config/user/tests.rs b/src/config/user/tests.rsindex 7656baf20..045b6aa5e 100644--- a/src/config/user/tests.rs+++ b/src/config/user/tests.rs@@ -1910,20 +1910,6 @@ fn test_hooks_none_project_uses_global() {assert_eq!(commands[0].template, "echo global");}-#[test]-fn test_hooks_in_overridable_config_is_empty() {- // Default hooks should be considered empty- let config = OverridableConfig::default();- assert!(config.is_empty());-- // With hooks set, should not be empty- let config = OverridableConfig {- hooks: parse_hooks("post-start = \"echo test\""),- ..Default::default()- };- assert!(!config.is_empty());-}-/// Validates that valid_user_config_keys() includes all hook types from HookType enum.////// The JsonSchema derivation should include all HooksConfig fields, which corresponddiff --git a/tests/integration_tests/list_config.rs b/tests/integration_tests/list_config.rsindex 1e40249e8..294bf72ae 100644--- a/tests/integration_tests/list_config.rs+++ b/tests/integration_tests/list_config.rs@@ -458,9 +458,7 @@ fn test_list_config_env_override_numeric_string_field(repo: TestRepo) {}/// Bad values in non-section fields (projects, skip-*-prompt) must still be-/// attributed to the file, not to env vars. These fields are NOT caught by-/// the OverridableConfig pre-validation (which only covers section fields) —-/// the UserConfig fallback validation catches them.+/// attributed to the file, not to env vars.#[rstest]fn test_list_config_malformed_non_section_field_warns_on_stderr(repo: TestRepo) {fs::write(@@ -496,7 +494,7 @@ fn test_list_config_validation_error_warns_on_stderr(repo: TestRepo) {});}-/// System config with a section-field error (caught by OverridableConfig).+/// System config with a section-field type error must be attributed to the file.#[rstest]fn test_list_config_malformed_system_config_warns_on_stderr(repo: TestRepo) {let system_config = repo.root_path().join("system-config.toml");@@ -514,8 +512,7 @@ fn test_list_config_malformed_system_config_warns_on_stderr(repo: TestRepo) {});}-/// System config with a non-section field error (skips OverridableConfig,-/// caught by the UserConfig fallback validation).+/// System config with a non-section field type error must be attributed to the file.#[rstest]fn test_list_config_malformed_system_config_non_section_field(repo: TestRepo) {let system_config = repo.root_path().join("system-config.toml");