mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-14 08:14:19 +00:00
fix(attribution): submodule leak, PR body nesting, shallow-clone bail, schema default
- attachCommitAttribution: when HEAD didn't move in our cwd, leave
pending attributions alone instead of dropping them. The case can be
a failed commit, `git reset HEAD~1`, OR `cd submodule && git commit`
(inner repo's HEAD moves, ours doesn't). Dropping was overly
aggressive and silently lost outer-repo edits in the submodule case.
- addAttributionToPR: mirror addCoAuthorToGitCommit's nested-match
rejection so `gh pr create --body "docs mention -b 'flag'"` picks the
outer `--body`, not the inner literal `-b`. Splicing into the inner
match would corrupt the body. Regression test added.
- getCommittedFileInfo: when `rev-parse --verify HEAD~1` fails, also
check `rev-list --count HEAD === 1` to confirm HEAD is the true
root commit. In a shallow clone, HEAD~1 is unreadable but the commit
has a parent recorded — falling back to `diff-tree --root` would
diff against the empty tree and over-attribute the entire commit.
Bail with a debug warning instead.
- generate-settings-schema: lift `default` (and `description`) out of
the inner `anyOf[N]` schema to the outer level when wrapping with
`legacyTypes`. Most JSON-schema-driven editors only surface
top-level defaults; burying the default under `anyOf` lost the
"enabled by default" hint. Also extend the default filter to
publish non-empty plain objects (so `gitCoAuthor`'s default can
appear). gitCoAuthor's source default updated to the runtime shape
`{commit: true, pr: true}` to match `normalizeGitCoAuthor`.
This commit is contained in:
parent
0103af5296
commit
9e731698ae
5 changed files with 128 additions and 24 deletions
|
|
@ -148,7 +148,7 @@ function convertSettingToJsonSchema(
|
|||
break;
|
||||
}
|
||||
|
||||
// Add default value for simple types only
|
||||
// Add default value for simple and object types
|
||||
if (setting.default !== undefined && setting.default !== null) {
|
||||
const defaultVal = setting.default;
|
||||
if (
|
||||
|
|
@ -159,6 +159,14 @@ function convertSettingToJsonSchema(
|
|||
schema.default = defaultVal;
|
||||
} else if (Array.isArray(defaultVal) && defaultVal.length > 0) {
|
||||
schema.default = defaultVal;
|
||||
} else if (
|
||||
typeof defaultVal === 'object' &&
|
||||
!Array.isArray(defaultVal) &&
|
||||
Object.keys(defaultVal).length > 0
|
||||
) {
|
||||
// Non-empty plain object — publish so IDE editors can surface the
|
||||
// default value (e.g. `{commit: true, pr: true}` for gitCoAuthor).
|
||||
schema.default = defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,11 +174,20 @@ function convertSettingToJsonSchema(
|
|||
// later expanded into an object), wrap with `anyOf` so existing values
|
||||
// in users' settings.json don't trip the IDE schema validator while
|
||||
// they wait for our migration to rewrite them on the next launch.
|
||||
//
|
||||
// Lift `description` and `default` to the outer (anyOf) level so IDE
|
||||
// editors that surface schema-driven defaults / descriptions still see
|
||||
// them — burying these behind `anyOf[N]` makes most validators ignore
|
||||
// the `default`, which loses the "enabled by default" hint for any
|
||||
// setting using `legacyTypes`.
|
||||
if (setting.legacyTypes && setting.legacyTypes.length > 0) {
|
||||
const description = schema.description;
|
||||
const defaultVal = schema.default;
|
||||
delete schema.description;
|
||||
delete schema.default;
|
||||
return {
|
||||
...(description ? { description } : {}),
|
||||
...(defaultVal !== undefined ? { default: defaultVal } : {}),
|
||||
anyOf: [...setting.legacyTypes.map((t) => ({ type: t })), schema],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue