fix(ai-review): 結果推送失敗時回報工作流失敗
This commit is contained in:
@@ -17,6 +17,33 @@ test('assertSafeBranchRef 拒絕路徑穿越分支名稱', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('assertSafeBranchRef 拒絕空白分支名稱', () => {
|
||||
for (const value of ['', ' ', null, undefined]) {
|
||||
assert.throws(
|
||||
() => gitref.assertSafeBranchRef(value, 'baseRef'),
|
||||
/baseRef 不可為空/,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('assertSafeBranchRef 拒絕不安全的 refspec 分支名稱', () => {
|
||||
for (const value of ['/feature', 'feature/', 'feature\\x', 'feature..x']) {
|
||||
assert.throws(
|
||||
() => gitref.assertSafeBranchRef(value, 'baseRef'),
|
||||
/不是安全的分支名稱/,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('assertSafeBranchRef 拒絕 git 不合法的分支名稱', () => {
|
||||
for (const value of ['feature.lock', 'feature@{x}', 'feature~x', 'feature^x']) {
|
||||
assert.throws(
|
||||
() => gitref.assertSafeBranchRef(value, 'baseRef'),
|
||||
/不是合法的 git 分支名稱/,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('resolveMergeBase 會在 git fetch 前拒絕不安全 baseRef', () => {
|
||||
assert.throws(
|
||||
() => gitrepo.resolveMergeBase(process.cwd(), '../../hooks/pre-push'),
|
||||
|
||||
@@ -98,6 +98,30 @@ test('resultFilesToCommit 在建問題模式無嚴重問題時只提交 exclusio
|
||||
);
|
||||
});
|
||||
|
||||
test('shouldFailMissingResultCommit 在結果檔需要 push 但未成功時回報失敗', () => {
|
||||
assert.equal(
|
||||
review.shouldFailMissingResultCommit({
|
||||
filesToCommit: ['.gitea/ai-review/findings/run.json'],
|
||||
resultCommitted: false,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
review.shouldFailMissingResultCommit({
|
||||
filesToCommit: ['.gitea/ai-review/findings/run.json'],
|
||||
resultCommitted: true,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
review.shouldFailMissingResultCommit({
|
||||
filesToCommit: [],
|
||||
resultCommitted: false,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('resolveOldIssueLinkComments 只標註舊追蹤 issue 連結', async () => {
|
||||
const edited = [];
|
||||
const fakeGitea = {
|
||||
|
||||
Reference in New Issue
Block a user