clawt 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -3631,6 +3631,7 @@ function registerRemoveCommand(program2) {
|
|
|
3631
3631
|
}
|
|
3632
3632
|
async function handleRemove(options) {
|
|
3633
3633
|
validateMainWorktree();
|
|
3634
|
+
requireProjectConfig();
|
|
3634
3635
|
const projectName = getProjectName();
|
|
3635
3636
|
logger.info(`remove \u547D\u4EE4\u6267\u884C\uFF0C\u9879\u76EE: ${projectName}`);
|
|
3636
3637
|
const allWorktrees = getProjectWorktrees();
|
|
@@ -3660,7 +3661,6 @@ async function handleRemove(options) {
|
|
|
3660
3661
|
const failures = [];
|
|
3661
3662
|
for (const wt of worktreesToRemove) {
|
|
3662
3663
|
try {
|
|
3663
|
-
await ensureOnMainWorkBranch();
|
|
3664
3664
|
removeWorktreeByPath(wt.path);
|
|
3665
3665
|
if (shouldDeleteBranch) {
|
|
3666
3666
|
deleteBranch(wt.branch);
|
|
@@ -3893,7 +3893,6 @@ async function executeSyncForBranch(targetWorktreePath, branch) {
|
|
|
3893
3893
|
async function handleSync(options) {
|
|
3894
3894
|
validateMainWorktree();
|
|
3895
3895
|
requireProjectConfig();
|
|
3896
|
-
await ensureOnMainWorkBranch();
|
|
3897
3896
|
logger.info(`sync \u547D\u4EE4\u6267\u884C\uFF0C\u5206\u652F: ${options.branch ?? "(\u672A\u6307\u5B9A)"}`);
|
|
3898
3897
|
const worktrees = getProjectWorktrees();
|
|
3899
3898
|
const worktree = await resolveTargetWorktree(worktrees, SYNC_RESOLVE_MESSAGES, options.branch);
|
package/docs/spec.md
CHANGED
|
@@ -328,7 +328,7 @@ export const PROJECTS_CONFIG_DIR = join(CLAWT_HOME, 'projects');
|
|
|
328
328
|
✗ 该项目尚未初始化,请先执行 clawt init -b<branchName>设置主工作分支
|
|
329
329
|
```
|
|
330
330
|
其他命令(list、resume、config、status、alias、projects、completion)不受影响,无需添加该校验。
|
|
331
|
-
> **实现细节**:`ensureOnMainWorkBranch()` 内部已通过 `getMainWorkBranch()` → `requireProjectConfig()` 完成了项目配置校验,因此调用了 `ensureOnMainWorkBranch` 的命令(create、run、validate、
|
|
331
|
+
> **实现细节**:`ensureOnMainWorkBranch()` 内部已通过 `getMainWorkBranch()` → `requireProjectConfig()` 完成了项目配置校验,因此调用了 `ensureOnMainWorkBranch` 的命令(create、run、validate、merge)**无需再显式调用 `requireProjectConfig()`**,避免重复校验。sync 和 remove 命令因不依赖主 worktree 的分支状态而不调用 `ensureOnMainWorkBranch`,需自行显式调用 `requireProjectConfig()`。reset 命令同理,也需自行调用 `requireProjectConfig()`。
|
|
332
332
|
3. **主分支名统一从项目级配置获取**:所有需要获取主分支名的场景(sync 中合并主分支、merge 中计算 merge-base、切回主分支等),统一使用项目级配置中的 `clawtMainWorkBranch`,不再通过 `getCurrentBranch(mainWorktreePath)` 动态获取。因为在新架构下,主 worktree 可能处于验证分支上,`getCurrentBranch` 会返回验证分支名而非真正的主工作分支名。
|
|
333
333
|
4. **测试文件全量更新**:本次重构涉及的所有命令(init、create、run、validate、sync、remove、merge、reset),其对应的测试文件必须同步更新,确保覆盖新增的验证分支逻辑、项目级配置逻辑和变更后的流程。
|
|
334
334
|
|
package/package.json
CHANGED
package/src/commands/remove.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
resolveTargetWorktrees,
|
|
24
24
|
getValidateBranchName,
|
|
25
25
|
deleteValidateBranch,
|
|
26
|
-
|
|
26
|
+
requireProjectConfig,
|
|
27
27
|
} from '../utils/index.js';
|
|
28
28
|
import type { WorktreeMultiResolveMessages } from '../utils/index.js';
|
|
29
29
|
|
|
@@ -56,6 +56,7 @@ export function registerRemoveCommand(program: Command): void {
|
|
|
56
56
|
*/
|
|
57
57
|
async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
58
58
|
validateMainWorktree();
|
|
59
|
+
requireProjectConfig();
|
|
59
60
|
|
|
60
61
|
const projectName = getProjectName();
|
|
61
62
|
logger.info(`remove 命令执行,项目: ${projectName}`);
|
|
@@ -98,8 +99,6 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
98
99
|
const failures: Array<{ path: string; error: string }> = [];
|
|
99
100
|
for (const wt of worktreesToRemove) {
|
|
100
101
|
try {
|
|
101
|
-
// 确保当前在主工作分支上
|
|
102
|
-
await ensureOnMainWorkBranch();
|
|
103
102
|
removeWorktreeByPath(wt.path);
|
|
104
103
|
if (shouldDeleteBranch) {
|
|
105
104
|
deleteBranch(wt.branch);
|
package/src/commands/sync.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
getMainWorkBranch,
|
|
24
24
|
rebuildValidateBranch,
|
|
25
25
|
getValidateBranchName,
|
|
26
|
-
ensureOnMainWorkBranch,
|
|
27
26
|
} from '../utils/index.js';
|
|
28
27
|
import type { WorktreeResolveMessages } from '../utils/index.js';
|
|
29
28
|
|
|
@@ -140,7 +139,6 @@ export async function executeSyncForBranch(targetWorktreePath: string, branch: s
|
|
|
140
139
|
async function handleSync(options: SyncOptions): Promise<void> {
|
|
141
140
|
validateMainWorktree();
|
|
142
141
|
requireProjectConfig();
|
|
143
|
-
await ensureOnMainWorkBranch();
|
|
144
142
|
|
|
145
143
|
logger.info(`sync 命令执行,分支: ${options.branch ?? '(未指定)'}`);
|
|
146
144
|
|
|
@@ -49,7 +49,6 @@ vi.mock('../../../src/utils/index.js', () => ({
|
|
|
49
49
|
requireProjectConfig: vi.fn().mockReturnValue({ clawtMainWorkBranch: 'main' }),
|
|
50
50
|
getValidateBranchName: vi.fn((name: string) => `clawt-validate-${name}`),
|
|
51
51
|
deleteValidateBranch: vi.fn(),
|
|
52
|
-
ensureOnMainWorkBranch: vi.fn(),
|
|
53
52
|
}));
|
|
54
53
|
|
|
55
54
|
import { registerRemoveCommand } from '../../../src/commands/remove.js';
|
|
@@ -51,7 +51,6 @@ vi.mock('../../../src/utils/index.js', () => ({
|
|
|
51
51
|
getMainWorkBranch: vi.fn().mockReturnValue('main'),
|
|
52
52
|
rebuildValidateBranch: vi.fn(),
|
|
53
53
|
getValidateBranchName: vi.fn((name: string) => `clawt-validate-${name}`),
|
|
54
|
-
ensureOnMainWorkBranch: vi.fn(),
|
|
55
54
|
}));
|
|
56
55
|
|
|
57
56
|
import { registerSyncCommand } from '../../../src/commands/sync.js';
|