fix: make agentrun trigger source fetch resilient
This commit is contained in:
+24
-4
@@ -148,14 +148,34 @@ async function status(config: UniDeskConfig): Promise<Record<string, unknown>> {
|
||||
|
||||
async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): Promise<Record<string, unknown>> {
|
||||
const source = await capture(config, g14SourceRoute, ["script", "--", [
|
||||
"set -eu",
|
||||
"set -u",
|
||||
"cd /root/agentrun-v01",
|
||||
"git fetch origin v0.1",
|
||||
"git merge --ff-only refs/remotes/origin/v0.1",
|
||||
"fetch_status=succeeded",
|
||||
"fetch_output=$(git fetch origin v0.1 2>&1)",
|
||||
"fetch_code=$?",
|
||||
"if [ \"$fetch_code\" -ne 0 ]; then fetch_status=failed; fi",
|
||||
"printf 'fetchStatus=%s\\n' \"$fetch_status\"",
|
||||
"printf 'fetchExitCode=%s\\n' \"$fetch_code\"",
|
||||
"printf 'fetchOutput=%s\\n' \"$fetch_output\" | tail -n 8",
|
||||
"origin_ref=$(git rev-parse refs/remotes/origin/v0.1 2>/dev/null || true)",
|
||||
"merge_status=skipped",
|
||||
"merge_code=0",
|
||||
"if [ -n \"$origin_ref\" ]; then",
|
||||
" merge_output=$(git merge --ff-only refs/remotes/origin/v0.1 2>&1)",
|
||||
" merge_code=$?",
|
||||
" if [ \"$merge_code\" -eq 0 ]; then merge_status=succeeded; else merge_status=failed; fi",
|
||||
" printf 'mergeStatus=%s\\n' \"$merge_status\"",
|
||||
" printf 'mergeExitCode=%s\\n' \"$merge_code\"",
|
||||
" printf 'mergeOutput=%s\\n' \"$merge_output\" | tail -n 8",
|
||||
" if [ \"$merge_code\" -ne 0 ]; then exit \"$merge_code\"; fi",
|
||||
"else",
|
||||
" printf 'mergeStatus=skipped-origin-missing\\n'",
|
||||
" printf 'originRefMissing=true\\n'",
|
||||
"fi",
|
||||
"printf 'sourceCommit='",
|
||||
"git rev-parse HEAD",
|
||||
"printf 'originV01='",
|
||||
"git rev-parse refs/remotes/origin/v0.1",
|
||||
"git rev-parse refs/remotes/origin/v0.1 2>/dev/null || true",
|
||||
"git status --short --branch",
|
||||
].join("\n")]);
|
||||
const sourceCommit = matchLine(source.stdout, "sourceCommit=");
|
||||
|
||||
Reference in New Issue
Block a user