dsh-svn-review 0.2.0 → 0.2.2
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/lib/index.js +45 -35
- package/lib/wc.js +13 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -150,40 +150,45 @@ export function apply(ctx) {
|
|
|
150
150
|
name: 'svn_change_set',
|
|
151
151
|
description: CHANGE_SET_DESCRIPTION,
|
|
152
152
|
parameters: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
type: 'object',
|
|
154
|
+
additionalProperties: false,
|
|
155
|
+
properties: {
|
|
156
|
+
path: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: '工作副本内的任意目录,会向上自动寻找 .svn/wc.db。省略时用当前工作目录。',
|
|
159
|
+
},
|
|
156
160
|
},
|
|
157
161
|
},
|
|
158
162
|
output: {
|
|
159
163
|
schema: {
|
|
160
164
|
type: 'object',
|
|
161
165
|
additionalProperties: false,
|
|
166
|
+
required: ['root', 'counts', 'files'],
|
|
162
167
|
properties: {
|
|
163
|
-
root: { type: 'string',
|
|
168
|
+
root: { type: 'string', description: '工作副本根目录' },
|
|
164
169
|
revision: { type: 'integer', description: '基线版本号,取 NODES 里最大的 revision' },
|
|
165
170
|
repository: { type: 'string', description: '仓库根 URL' },
|
|
166
171
|
counts: {
|
|
167
172
|
type: 'object',
|
|
168
173
|
additionalProperties: false,
|
|
169
|
-
required:
|
|
174
|
+
required: ['M', 'A', 'D', '!', 'C'],
|
|
170
175
|
properties: {
|
|
171
|
-
M: { type: 'integer'
|
|
172
|
-
A: { type: 'integer'
|
|
173
|
-
D: { type: 'integer'
|
|
174
|
-
'!': { type: 'integer'
|
|
175
|
-
C: { type: 'integer'
|
|
176
|
+
M: { type: 'integer' },
|
|
177
|
+
A: { type: 'integer' },
|
|
178
|
+
D: { type: 'integer' },
|
|
179
|
+
'!': { type: 'integer' },
|
|
180
|
+
C: { type: 'integer' },
|
|
176
181
|
},
|
|
177
182
|
},
|
|
178
183
|
files: {
|
|
179
184
|
type: 'array',
|
|
180
|
-
required: true,
|
|
181
185
|
items: {
|
|
182
186
|
type: 'object',
|
|
183
187
|
additionalProperties: false,
|
|
188
|
+
required: ['status', 'path'],
|
|
184
189
|
properties: {
|
|
185
|
-
status: { type: 'string',
|
|
186
|
-
path: { type: 'string'
|
|
190
|
+
status: { type: 'string', enum: ['M', 'A', 'D', '!', 'C'] },
|
|
191
|
+
path: { type: 'string' },
|
|
187
192
|
size: { type: 'integer', description: '修改后的大小(仅 M)' },
|
|
188
193
|
},
|
|
189
194
|
},
|
|
@@ -204,7 +209,15 @@ export function apply(ctx) {
|
|
|
204
209
|
`工作副本 ${value.root}(基线 r${value.revision ?? '?'}):`
|
|
205
210
|
+ `M=${counts.M} A=${counts.A} D=${counts.D} !=${counts['!']} C=${counts.C}`,
|
|
206
211
|
)
|
|
207
|
-
|
|
212
|
+
// 清单过长会挤占上下文,而且一个真实的变更集不该有上千个文件。
|
|
213
|
+
// 截断但明确告知,不要静默吞掉。
|
|
214
|
+
const shown = value.files.slice(0, 300)
|
|
215
|
+
for (const file of shown) lines.push(` ${file.status} ${file.path}`)
|
|
216
|
+
if (value.files.length > shown.length) {
|
|
217
|
+
lines.push(` …另有 ${value.files.length - shown.length} 个未列出`)
|
|
218
|
+
lines.push(' 提示:变更集这么大通常说明判断有问题,而不是你真的改了这么多文件。')
|
|
219
|
+
lines.push(' 可先用 counts 确认规模;若确认属实,再按目录分批核对。')
|
|
220
|
+
}
|
|
208
221
|
}
|
|
209
222
|
const languages = value.project?.languages ?? []
|
|
210
223
|
if (languages.length > 0) {
|
|
@@ -246,35 +259,38 @@ export function apply(ctx) {
|
|
|
246
259
|
},
|
|
247
260
|
}
|
|
248
261
|
},
|
|
249
|
-
presentCall: (args) => ({
|
|
250
|
-
card: 'generic',
|
|
251
|
-
title: '读取 SVN 变更集',
|
|
252
|
-
kind: 'other',
|
|
253
|
-
rawInput: args,
|
|
254
|
-
}),
|
|
255
262
|
})
|
|
256
263
|
|
|
257
264
|
ctx.tools.register({
|
|
258
265
|
name: 'project_profile',
|
|
259
266
|
description: PROFILE_DESCRIPTION,
|
|
260
267
|
parameters: {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
268
|
+
type: 'object',
|
|
269
|
+
additionalProperties: false,
|
|
270
|
+
properties: {
|
|
271
|
+
path: {
|
|
272
|
+
type: 'string',
|
|
273
|
+
description: '工作目录或其中任意子目录。省略时用当前工作目录。',
|
|
274
|
+
},
|
|
264
275
|
},
|
|
265
276
|
},
|
|
266
277
|
output: {
|
|
267
278
|
schema: {
|
|
268
279
|
type: 'object',
|
|
269
280
|
additionalProperties: false,
|
|
281
|
+
required: ['root', 'languages', 'testInfra', 'concurrencyHints', 'notes'],
|
|
270
282
|
properties: {
|
|
271
|
-
root: { type: 'string'
|
|
283
|
+
root: { type: 'string' },
|
|
272
284
|
projectName: { type: 'string', description: '检测到的工程名,用于匹配 projects/<名>.md' },
|
|
273
|
-
languages: {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
285
|
+
languages: {
|
|
286
|
+
type: 'array',
|
|
287
|
+
items: { type: 'object' },
|
|
288
|
+
description: '每种识别出的语言及其档案路径',
|
|
289
|
+
},
|
|
290
|
+
build: { type: 'object', description: '构建系统信息;未识别时不返回该字段' },
|
|
291
|
+
testInfra: { type: 'array', items: { type: 'string' } },
|
|
292
|
+
concurrencyHints: { type: 'array', items: { type: 'string' } },
|
|
293
|
+
notes: { type: 'array', items: { type: 'string' } },
|
|
278
294
|
rules: { type: 'object', description: '各层规范文件的绝对路径' },
|
|
279
295
|
},
|
|
280
296
|
},
|
|
@@ -338,11 +354,5 @@ export function apply(ctx) {
|
|
|
338
354
|
},
|
|
339
355
|
}
|
|
340
356
|
},
|
|
341
|
-
presentCall: (args) => ({
|
|
342
|
-
card: 'generic',
|
|
343
|
-
title: '识别项目技术栈',
|
|
344
|
-
kind: 'other',
|
|
345
|
-
rawInput: args,
|
|
346
|
-
}),
|
|
347
357
|
})
|
|
348
358
|
}
|
package/lib/wc.js
CHANGED
|
@@ -120,31 +120,30 @@ export async function readChangeSet(start, options = {}) {
|
|
|
120
120
|
}
|
|
121
121
|
if (!stat.isFile()) continue
|
|
122
122
|
|
|
123
|
-
//
|
|
123
|
+
// 快路径:大小与 mtime 都与快照一致 → 未修改,跳过哈希(svn status 也是这么快判的)。
|
|
124
|
+
//
|
|
125
|
+
// 反过来不成立:快照对不上**不能**证明文件被改过。
|
|
126
|
+
// - 复制/还原工作副本会把 mtime 全部刷新,内容一个字节没动;
|
|
127
|
+
// - eol 翻译、快照本身的漂移会让尺寸和 translated_size 不等;
|
|
128
|
+
// - SVN 正在跑(update/commit)时 DB 与磁盘可能短暂不一致。
|
|
129
|
+
// 这几种情况若直接判 M,会一次性报出几千个假改动。所以判 M 一律要有哈希证据。
|
|
124
130
|
const snapshotSize = node.snapshotSize
|
|
125
|
-
if (typeof snapshotSize === 'number' && stat.size !== snapshotSize) {
|
|
126
|
-
files.push({ status: 'M', path: node.relpath, size: stat.size })
|
|
127
|
-
counts.M += 1
|
|
128
|
-
continue
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 快路径二:大小和 mtime 都和快照对得上,跳过哈希。
|
|
132
|
-
// 文件系统时间精度各平台不同,留 2 秒余量;对不上再算 SHA-1 兜底。
|
|
133
131
|
const snapshotMtime = node.snapshotMtime
|
|
134
132
|
if (
|
|
135
133
|
typeof snapshotSize === 'number'
|
|
134
|
+
&& stat.size === snapshotSize
|
|
136
135
|
&& typeof snapshotMtime === 'number'
|
|
137
136
|
&& Math.abs(stat.mtimeMs - snapshotMtime / 1000) < 2000
|
|
138
137
|
) {
|
|
139
138
|
continue
|
|
140
139
|
}
|
|
141
140
|
|
|
142
|
-
//
|
|
141
|
+
// 慢路径:内容与基线校验和一致就说明没改,不管快照字段说什么。
|
|
143
142
|
const base = checksumHex(node.checksum)
|
|
144
|
-
if (base
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
if (base !== null && sha1OfFile(absolute) === base) continue
|
|
144
|
+
|
|
145
|
+
files.push({ status: 'M', path: node.relpath, size: stat.size })
|
|
146
|
+
counts.M += 1
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
for (const node of workingNodes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-svn-review",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"displayName": "DSH SVN Review",
|
|
5
5
|
"description": "SVN change-set scoping plus language and version detection for DeepSeek Harness code review: reads .svn/wc.db directly (no svn.exe), pins down the project language and version, and hands over the matching review rules so findings are judged by that language instead of generic ones.",
|
|
6
6
|
"keywords": [
|