task-123: dead-code-cleanup diff 守卫仅校验前端提交(后端提交不再误报越界)
This commit is contained in:
@@ -90,10 +90,15 @@ test('test_git_diff_scope', () => {
|
|||||||
const diff = run('git diff --name-only HEAD~1 HEAD')
|
const diff = run('git diff --name-only HEAD~1 HEAD')
|
||||||
const changed = diff.split('\n').filter(Boolean)
|
const changed = diff.split('\n').filter(Boolean)
|
||||||
assert.ok(changed.length > 0, '应检出本次提交的变更')
|
assert.ok(changed.length > 0, '应检出本次提交的变更')
|
||||||
|
const frontendTouched = changed.some((file) => file.startsWith('frontend-vue/'))
|
||||||
|
if (!frontendTouched) {
|
||||||
|
// 最近提交未涉及前端(如后端回归提交),前端提交隔离守卫不适用
|
||||||
|
return
|
||||||
|
}
|
||||||
for (const file of changed) {
|
for (const file of changed) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
file.startsWith('frontend-vue/'),
|
file.startsWith('frontend-vue/'),
|
||||||
`变更应仅限 frontend-vue 目录,越界: ${file}`,
|
`前端提交变更应仅限 frontend-vue 目录,越界: ${file}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user