♻️ refactor(vscode): 设置项 autoBuildBranch 换成发布分支前缀与 Jenkins 任务

Claude-Session: https://claude.ai/code/session_01HTMgwaE3woqM5yvsHiuSAa
This commit is contained in:
cruldra committed 2026-08-31 23:38:53 +08:00
1 parent fa32d4a88b
commit 6f59b4f3fd
13 files changed
+149 -66

No files matched your search

+25 -12
View File
@@ -15,6 +15,7 @@ import { readFileSync } from 'node:fs'
import path from 'node:path'
import { seedCommitProfilePath } from '../cc/commitProfile'
import { listClaudeProfiles } from '../cc/profiles'
import { normalizeReleasePrefix } from '../git/release'
/**
* Fallback prompt strings used when the on-disk markdown can't be read.
@@ -88,11 +89,14 @@ export interface Settings {
/** Day-to-day development branch (e.g. `main`). Jenkins doesn't watch it. */
devBranch: string
/**
* Branch the Gitea webhook → Jenkins job listens on. Empty string means
* "same as `devBranch`", in which case the branch-sync button stays
* disabled because there's nothing to fast-forward.
* 发布分支名前缀(如 `release/`),远端该前缀下字典序最大的分支即当期发布点。
* 读出时已归一化:trim、空回退默认、末尾补 `/`。
*/
autoBuildBranch: string
releaseBranchPrefix: string
/** 正式服部署的 Jenkins 任务名;空串 = 不提供「部署到正式服」。 */
jenkinsJob: string
/** Jenkins 任务的 `REMOTE_HOST` 参数取值,空回退 `正式服`。 */
jenkinsProdHost: string
/**
* Directory template for the worktree created when implementing a plan.
* Placeholders: `$project_root` (workspace abs path), `$project_name` (its
@@ -215,7 +219,9 @@ function defaults(ctx: ExtensionContext): Settings {
autoReview: true,
reviewPrompt: readDefaultPrompt(ctx.extensionPath, 'review'),
devBranch: 'main',
autoBuildBranch: '',
releaseBranchPrefix: 'release/',
jenkinsJob: '',
jenkinsProdHost: '正式服',
worktreeDirectory: '~/Sources/worktree/$project_name/$feature_name',
worktreeOpenWith: 'vscode',
pycharmCommand: 'pycharm',
@@ -266,12 +272,17 @@ export function getSettings(ctx: ExtensionContext): Settings {
const devBranch = typeof stored.devBranch === 'string' && stored.devBranch.length > 0
? stored.devBranch
: base.devBranch
// autoBuildBranch is kept as-is — '' is meaningful ("follow devBranch, sync
// disabled"), so we don't coerce to a default here. Anything non-string
// (legacy installs that never wrote it) collapses to ''.
const autoBuildBranch = typeof stored.autoBuildBranch === 'string'
? stored.autoBuildBranch
: base.autoBuildBranch
// 发布前缀读出时归一化(空 → 默认、补尾 `/`),下游拼分支名不用再防御。
const releaseBranchPrefix = normalizeReleasePrefix(
typeof stored.releaseBranchPrefix === 'string' ? stored.releaseBranchPrefix : base.releaseBranchPrefix,
)
// jenkinsJob:'' 有意义(= 不提供部署动作),只认字符串类型。
const jenkinsJob = typeof stored.jenkinsJob === 'string'
? stored.jenkinsJob.trim()
: base.jenkinsJob
const jenkinsProdHost = typeof stored.jenkinsProdHost === 'string' && stored.jenkinsProdHost.trim().length > 0
? stored.jenkinsProdHost.trim()
: base.jenkinsProdHost
// worktree dir template: empty/blank means "use the default template", so
// fall back to base (unlike the hook paths below, where '' is meaningful).
const worktreeDirectory = typeof stored.worktreeDirectory === 'string' && stored.worktreeDirectory.length > 0
@@ -349,7 +360,9 @@ export function getSettings(ctx: ExtensionContext): Settings {
autoReview,
reviewPrompt,
devBranch,
autoBuildBranch,
releaseBranchPrefix,
jenkinsJob,
jenkinsProdHost,
worktreeDirectory,
worktreeOpenWith,
pycharmCommand,