clawt 3.4.3 → 3.4.4
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 +7 -0
- package/package.json +1 -1
- package/src/commands/create.ts +3 -0
- package/src/commands/run.ts +2 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/validation.ts +12 -1
package/dist/index.js
CHANGED
|
@@ -1367,6 +1367,11 @@ function validateHeadExists() {
|
|
|
1367
1367
|
throw new ClawtError(MESSAGES.HEAD_NOT_FOUND);
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
1370
|
+
function validateWorkingDirClean() {
|
|
1371
|
+
if (!isWorkingDirClean()) {
|
|
1372
|
+
throw new ClawtError(MESSAGES.MAIN_WORKTREE_DIRTY);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1370
1375
|
function runPreChecks(options) {
|
|
1371
1376
|
if (options.mainWorktree) {
|
|
1372
1377
|
validateMainWorktree();
|
|
@@ -3871,6 +3876,7 @@ async function handleCreate(options) {
|
|
|
3871
3876
|
runPreChecks({ mainWorktree: true, headExists: true });
|
|
3872
3877
|
await guardMainWorkBranch();
|
|
3873
3878
|
await ensureOnMainWorkBranch();
|
|
3879
|
+
validateWorkingDirClean();
|
|
3874
3880
|
const count = Number(options.number);
|
|
3875
3881
|
if (!Number.isInteger(count) || count <= 0) {
|
|
3876
3882
|
throw new ClawtError(
|
|
@@ -4014,6 +4020,7 @@ async function handleRun(options) {
|
|
|
4014
4020
|
if (!options.dryRun) {
|
|
4015
4021
|
await guardMainWorkBranch();
|
|
4016
4022
|
await ensureOnMainWorkBranch();
|
|
4023
|
+
validateWorkingDirClean();
|
|
4017
4024
|
}
|
|
4018
4025
|
if (options.file && options.tasks) {
|
|
4019
4026
|
throw new ClawtError(MESSAGES.FILE_AND_TASKS_CONFLICT);
|
package/package.json
CHANGED
package/src/commands/create.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
runPreChecks,
|
|
8
8
|
createWorktrees,
|
|
9
9
|
ensureOnMainWorkBranch,
|
|
10
|
+
validateWorkingDirClean,
|
|
10
11
|
getValidateBranchName,
|
|
11
12
|
printSuccess,
|
|
12
13
|
printInfo,
|
|
@@ -40,6 +41,8 @@ async function handleCreate(options: CreateOptions): Promise<void> {
|
|
|
40
41
|
|
|
41
42
|
await ensureOnMainWorkBranch();
|
|
42
43
|
|
|
44
|
+
validateWorkingDirClean();
|
|
45
|
+
|
|
43
46
|
const count = Number(options.number);
|
|
44
47
|
|
|
45
48
|
// 校验创建数量必须为正整数
|
package/src/commands/run.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
executeBatchTasks,
|
|
21
21
|
printDryRunPreview,
|
|
22
22
|
ensureOnMainWorkBranch,
|
|
23
|
+
validateWorkingDirClean,
|
|
23
24
|
guardMainWorkBranch,
|
|
24
25
|
} from '../utils/index.js';
|
|
25
26
|
|
|
@@ -126,6 +127,7 @@ async function handleRun(options: RunOptions): Promise<void> {
|
|
|
126
127
|
if (!options.dryRun) {
|
|
127
128
|
await guardMainWorkBranch();
|
|
128
129
|
await ensureOnMainWorkBranch();
|
|
130
|
+
validateWorkingDirClean();
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
// 互斥校验:--file 和 --tasks 不能同时使用
|
package/src/utils/index.ts
CHANGED
|
@@ -50,7 +50,7 @@ export {
|
|
|
50
50
|
createBranch,
|
|
51
51
|
} from './git.js';
|
|
52
52
|
export { sanitizeBranchName, generateBranchNames, validateBranchesNotExist } from './branch.js';
|
|
53
|
-
export { validateMainWorktree, validateGitInstalled, validateClaudeCodeInstalled, validateHeadExists, runPreChecks } from './validation.js';
|
|
53
|
+
export { validateMainWorktree, validateGitInstalled, validateClaudeCodeInstalled, validateHeadExists, validateWorkingDirClean, runPreChecks } from './validation.js';
|
|
54
54
|
export { createWorktrees, getProjectWorktrees, getProjectWorktreeDir, cleanupWorktrees, getWorktreeStatus, createWorktreesByBranches } from './worktree.js';
|
|
55
55
|
export { loadConfig, writeDefaultConfig, writeConfig, saveConfig, getConfigValue, ensureClawtDirs, parseConcurrency } from './config.js';
|
|
56
56
|
export { printSuccess, printError, printWarning, printInfo, printHint, printSeparator, printDoubleSeparator, confirmAction, confirmDestructiveAction, formatWorktreeStatus, isWorktreeIdle, formatDuration, formatRelativeTime, formatDiskSize, formatLocalISOString } from './formatter.js';
|
package/src/utils/validation.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MESSAGES } from '../constants/index.js';
|
|
2
2
|
import { ClawtError } from '../errors/index.js';
|
|
3
3
|
import { execCommand } from './shell.js';
|
|
4
|
-
import { getGitCommonDir } from './git.js';
|
|
4
|
+
import { getGitCommonDir, isWorkingDirClean } from './git.js';
|
|
5
5
|
import { requireProjectConfig, guardMainWorkBranchExists } from './project-config.js';
|
|
6
6
|
|
|
7
7
|
/** 统一前置校验选项 */
|
|
@@ -73,6 +73,17 @@ export function validateHeadExists(): void {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* 校验主分支工作区和暂存区是否干净
|
|
78
|
+
* 当存在未提交的更改时抛出错误,防止基于脏状态创建 worktree
|
|
79
|
+
* @throws {ClawtError} 工作区或暂存区不干净时抛出
|
|
80
|
+
*/
|
|
81
|
+
export function validateWorkingDirClean(): void {
|
|
82
|
+
if (!isWorkingDirClean()) {
|
|
83
|
+
throw new ClawtError(MESSAGES.MAIN_WORKTREE_DIRTY);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
76
87
|
/**
|
|
77
88
|
* 统一前置校验入口,按需执行各项校验
|
|
78
89
|
* @param {PreCheckOptions} options - 校验选项
|