fix(build-worker-artifacts): dirty 判斷排除自己的輸出目錄

.worker-builds/ 是本腳本的輸出,在成品寫出、commit 之前永遠是 untracked——
拿它判斷「原始碼乾不乾淨」是自己把自己判成髒的假陽性。git status pathspec
排除 .worker-builds 後才是「原始碼有沒有未 commit 變更」的真實訊號。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 13:33:32 +08:00
parent 3b0238bb28
commit dcb6ad693b
+4 -1
View File
@@ -131,7 +131,10 @@ function sourceCommitFor(dir) {
function repoHead() {
try {
const sha = execSync('git rev-parse HEAD', { cwd: REPO, encoding: 'utf8' }).trim();
const dirty = execSync('git status --porcelain', { cwd: REPO, encoding: 'utf8' }).trim();
// .worker-builds 是本腳本自己的輸出目錄——它在「寫出成品之前」永遠是 untracked,
// 拿它判斷「原始碼乾不乾淨」是假陽性(自己把自己判成髒)。排除掉才是真正的
// 「原始碼有沒有未 commit 的變更」。
const dirty = execSync('git status --porcelain -- . ":(exclude).worker-builds"', { cwd: REPO, encoding: 'utf8' }).trim();
return { sha, dirty: !!dirty };
} catch {
return { sha: null, dirty: null };