Merge pull request #2889 from MoerAI/fix/git-master-config-ignored
fix(config): apply git_master defaults when section is missing (fixes #2040)
This commit is contained in:
@@ -969,6 +969,45 @@ describe("GitMasterConfigSchema", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("OhMyOpenCodeConfigSchema - git_master defaults (#2040)", () => {
|
||||||
|
test("git_master defaults are applied when section is missing from config", () => {
|
||||||
|
//#given
|
||||||
|
const config = {}
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.data.git_master).toBeDefined()
|
||||||
|
expect(result.data.git_master.commit_footer).toBe(true)
|
||||||
|
expect(result.data.git_master.include_co_authored_by).toBe(true)
|
||||||
|
expect(result.data.git_master.git_env_prefix).toBe("GIT_MASTER=1")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("git_master respects explicit false values", () => {
|
||||||
|
//#given
|
||||||
|
const config = {
|
||||||
|
git_master: {
|
||||||
|
commit_footer: false,
|
||||||
|
include_co_authored_by: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.data.git_master.commit_footer).toBe(false)
|
||||||
|
expect(result.data.git_master.include_co_authored_by).toBe(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("skills schema", () => {
|
describe("skills schema", () => {
|
||||||
test("accepts skills.sources configuration", () => {
|
test("accepts skills.sources configuration", () => {
|
||||||
//#given
|
//#given
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ export const OhMyOpenCodeConfigSchema = z.object({
|
|||||||
model_capabilities: ModelCapabilitiesConfigSchema.optional(),
|
model_capabilities: ModelCapabilitiesConfigSchema.optional(),
|
||||||
openclaw: OpenClawConfigSchema.optional(),
|
openclaw: OpenClawConfigSchema.optional(),
|
||||||
babysitting: BabysittingConfigSchema.optional(),
|
babysitting: BabysittingConfigSchema.optional(),
|
||||||
git_master: GitMasterConfigSchema.optional(),
|
git_master: GitMasterConfigSchema.default({
|
||||||
|
commit_footer: true,
|
||||||
|
include_co_authored_by: true,
|
||||||
|
git_env_prefix: "GIT_MASTER=1",
|
||||||
|
}),
|
||||||
browser_automation_engine: BrowserAutomationConfigSchema.optional(),
|
browser_automation_engine: BrowserAutomationConfigSchema.optional(),
|
||||||
websearch: WebsearchConfigSchema.optional(),
|
websearch: WebsearchConfigSchema.optional(),
|
||||||
tmux: TmuxConfigSchema.optional(),
|
tmux: TmuxConfigSchema.optional(),
|
||||||
|
|||||||
@@ -188,9 +188,9 @@ export function loadPluginConfig(
|
|||||||
migrateLegacyConfigFile(projectDetected.path);
|
migrateLegacyConfigFile(projectDetected.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load user config first (base)
|
// Load user config first (base). Parse empty config through Zod to apply field defaults.
|
||||||
let config: OhMyOpenCodeConfig =
|
let config: OhMyOpenCodeConfig =
|
||||||
loadConfigFromPath(userConfigPath, ctx) ?? {};
|
loadConfigFromPath(userConfigPath, ctx) ?? OhMyOpenCodeConfigSchema.parse({});
|
||||||
|
|
||||||
// Override with project config
|
// Override with project config
|
||||||
const projectConfig = loadConfigFromPath(projectConfigPath, ctx);
|
const projectConfig = loadConfigFromPath(projectConfigPath, ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user