chore: unify log formatting
This commit is contained in:
+7
-6
@@ -3,6 +3,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js';
|
||||
import { line, ok, warn } from './log.js';
|
||||
|
||||
const ACTION_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const GENERATED_SYNC_PATHS = [FINDINGS_PATH, '.gitea/ai-review/exclusions.json'];
|
||||
@@ -78,11 +79,11 @@ export function cloneRepo(workspace, _spawnSync = spawnSync) {
|
||||
return withAskpass(workspace, credEnv => {
|
||||
if (!fs.existsSync(repoDir)) {
|
||||
run(['clone', '--depth=1', '--branch', PR_HEAD_BRANCH, remoteUrl, repoDir], workspace, credEnv);
|
||||
console.log(` ✅ repo cloned to ${repoDir}`);
|
||||
ok(`repo cloned to ${repoDir}`);
|
||||
} else {
|
||||
run(['fetch', 'origin', PR_HEAD_BRANCH], repoDir, credEnv);
|
||||
run(['checkout', PR_HEAD_BRANCH], repoDir);
|
||||
console.log(` ✅ repo already exists, fetched latest`);
|
||||
ok('repo already exists, fetched latest');
|
||||
}
|
||||
return repoDir;
|
||||
});
|
||||
@@ -130,7 +131,7 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync,
|
||||
|
||||
const status = run(['status', '--porcelain'], repoDir);
|
||||
if (!status) {
|
||||
console.log(' sync files 無變更,跳過 commit');
|
||||
line('sync files 無變更,跳過 commit');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,12 +140,12 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync,
|
||||
const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
|
||||
try {
|
||||
run(['push', remoteUrl, PR_HEAD_BRANCH], repoDir, credEnv);
|
||||
console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH} review_outcome=${reviewOutcome}`);
|
||||
ok(`persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH} review_outcome=${reviewOutcome}`);
|
||||
} catch (pushErr) {
|
||||
console.log(` ⚠️ Step7 commit 成功但 push 失敗: commit=${commitHash} push=${PR_HEAD_BRANCH} review_outcome=${reviewOutcome} error=${pushErr.message}`);
|
||||
warn(`Step7 commit 成功但 push 失敗: commit=${commitHash} push=${PR_HEAD_BRANCH} review_outcome=${reviewOutcome} error=${pushErr.message}`);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
|
||||
warn(`Runner failed: commit/push 失敗: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user