Compare commits
3 Commits
v0.0.4
...
v0.0.5-beta.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 69e3b33558 | |||
| c70a818986 | |||
| 684c35bc00 |
@@ -11,7 +11,7 @@
|
||||
5. 從PR問題表格中取出所有舊問題,依照等級排序後 Comment 到 Push Request
|
||||
6. 從PR問題表格中取出所有新問題,排除嚴重等級的問題後 Comment 到 Push Request
|
||||
7. 從PR問題表格中取出所有新問題,將每個嚴重等級的問題 Comment 到 Push Request
|
||||
8. Commit 問題檔案
|
||||
8. Commit 問題檔案,將 workspace 中實際存在的同步檔覆蓋到記憶區;workspace 不存在但記憶區已存在的同步檔則移除後再同步,避免 `git add` 因缺檔 pathspec 失敗
|
||||
9. 如果PR問題表格中有嚴重問題,則不要讓 workflow 執行成功(exit 1)
|
||||
|
||||
# 設計
|
||||
@@ -227,4 +227,4 @@ Amazon Q:直接輸入 `triage-findings 問題原始檔(文字或截圖)`
|
||||
|
||||
### 版本包含
|
||||
|
||||
提交時一併包含 `triage-findings` skill 與各平台入口檔;已存在檔案一律覆蓋,同步到最新內容。
|
||||
提交時一併包含 `triage-findings` skill 與各平台入口檔;已存在檔案一律覆蓋,同步到最新內容;若 workspace 已移除某個同步檔,記憶區中的對應檔案也會一併刪除,讓 commit 結果與 workspace 保持一致。
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
- 已驗收:log 已明確顯示 `.gitea/ai-review/findings.json` 與 `.gitea/ai-review/exclusions.json` 都是 `JSON 格式正確`。
|
||||
|
||||
## 階段八:記憶區 commit/push 與錯誤處理
|
||||
- 目標:記憶區能成功 commit/push,且一併包含 `triage-findings` skill 與各平台入口檔;skill 檔案已存在時一律以來源覆蓋,達到同步效果;錯誤時有明確 log,流程結束有總結訊息。
|
||||
- 驗收:log 有「persisted findings」、「commit=...」、「push=...」等訊息,且能看出 skill 相關檔案已一併提交並被覆蓋同步;錯誤時有「Runner failed: ...」等明確錯誤說明。
|
||||
- 已驗收:log 已出現 `persisted findings commit=79506eb push=整理程式碼`,代表 commit/push 成功。
|
||||
- 目標:記憶區能成功 commit/push,且一併包含 `triage-findings` skill 與各平台入口檔;skill 檔案已存在時一律以來源覆蓋,缺少的同步檔則從記憶區刪除,達到鏡像同步效果;錯誤時有明確 log,流程結束有總結訊息。
|
||||
- 驗收:log 有「persisted findings」、「commit=...」、「push=...」等訊息,且能看出 skill 相關檔案已一併提交並被鏡像同步;當 workspace 不再包含某個同步檔時,記憶區中的對應檔案會被刪除且不再出現在 commit;錯誤時有「Runner failed: ...」等明確錯誤說明。
|
||||
- 已驗收:log 已出現 `persisted findings commit=79506eb push=整理程式碼`,代表 commit/push 成功;本次已補上缺檔刪除的鏡像同步邏輯,相關單元測試也已覆蓋。
|
||||
|
||||
## 階段九:阻擋嚴重問題 PR(第 8 點)
|
||||
- 目標:如果 PR 問題表格中有嚴重(critical)問題,workflow 需直接 exit 1,不讓流程成功。
|
||||
|
||||
+21
-5
@@ -65,16 +65,32 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync)
|
||||
run(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
||||
run(['config', 'user.name', 'AI Review Bot'], repoDir);
|
||||
|
||||
// Always copy source files over the repo copy so skill files stay in sync.
|
||||
const existingSyncPaths = [];
|
||||
const missingSyncPaths = [];
|
||||
|
||||
// Mirror sync files from workspace into the repo copy.
|
||||
for (const relPath of SYNC_PATHS) {
|
||||
const src = path.join(workspace, relPath);
|
||||
const dest = path.join(repoDir, relPath);
|
||||
if (!fs.existsSync(src)) continue;
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
if (fs.existsSync(src)) {
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
existingSyncPaths.push(relPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fs.existsSync(dest)) {
|
||||
fs.rmSync(dest, { force: true });
|
||||
}
|
||||
missingSyncPaths.push(relPath);
|
||||
}
|
||||
|
||||
run(['add', ...SYNC_PATHS], repoDir);
|
||||
if (existingSyncPaths.length > 0) {
|
||||
run(['add', ...existingSyncPaths], repoDir);
|
||||
}
|
||||
if (missingSyncPaths.length > 0) {
|
||||
run(['rm', '--cached', '--ignore-unmatch', '--', ...missingSyncPaths], repoDir);
|
||||
}
|
||||
|
||||
const status = run(['status', '--porcelain'], repoDir);
|
||||
if (!status) {
|
||||
|
||||
@@ -101,6 +101,20 @@ describe('commitAndPush', () => {
|
||||
assert.ok(!addCall.args.includes('README.md'));
|
||||
});
|
||||
|
||||
it('removes missing sync paths from the repo copy', async () => {
|
||||
const missingPath = path.join(workspace, '.amazonq/rules/triage-findings.md');
|
||||
fs.rmSync(missingPath, { force: true });
|
||||
fs.rmSync(path.join(workspace, 'repo', '.amazonq/rules/triage-findings.md'), { force: true });
|
||||
const spawn = makeSpawn();
|
||||
|
||||
await commitAndPush(workspace, path.join(workspace, 'repo'), spawn);
|
||||
|
||||
const rmCall = spawn.calls.find(c => c.args[0] === 'rm');
|
||||
assert.ok(rmCall, 'expected git rm to run');
|
||||
assert.ok(rmCall.args.includes('.amazonq/rules/triage-findings.md'));
|
||||
assert.equal(fs.existsSync(path.join(workspace, 'repo', '.amazonq/rules/triage-findings.md')), false);
|
||||
});
|
||||
|
||||
it('overwrites existing repo copies with workspace files', async () => {
|
||||
const repoDir = path.join(workspace, 'repo');
|
||||
fs.writeFileSync(path.join(repoDir, '.github/skills/triage-findings/SKILL.md'), 'stale');
|
||||
|
||||
Reference in New Issue
Block a user