Compare commits

...

2 Commits

Author SHA1 Message Date
chyoo e74c296b7e harden release promotion fallback on conflict
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-07 18:14:35 +09:00
chyoo ce99890dc8 harden release promotion fallback on conflict 2026-07-07 18:14:12 +09:00
+28
View File
@@ -726,7 +726,11 @@ export class AppsService {
commitSha, commitSha,
], { cwd: workDir }); ], { cwd: workDir });
} catch { } catch {
try {
await this.resolveReleaseMergeByTakingSourceOnConflict(gitBin, workDir, mergeOptions, commitSha, repository); await this.resolveReleaseMergeByTakingSourceOnConflict(gitBin, workDir, mergeOptions, commitSha, repository);
} catch {
await this.promoteReleaseBySourceSnapshot(gitBin, workDir, commitSha, targetBranch, repository);
}
} }
} }
} else { } else {
@@ -774,6 +778,30 @@ export class AppsService {
await execFileAsync(gitBin, ['commit', '--allow-empty', '-m', `${repository} release promotion merge`], { cwd: workDir }); await execFileAsync(gitBin, ['commit', '--allow-empty', '-m', `${repository} release promotion merge`], { cwd: workDir });
} }
private async promoteReleaseBySourceSnapshot(
gitBin: string,
workDir: string,
commitSha: string,
targetBranch: string,
repository: string,
) {
await this.resetPromotionWorktree(gitBin, workDir);
await execFileAsync(gitBin, [
'checkout',
'-B',
targetBranch,
`origin/${targetBranch}`,
], { cwd: workDir });
await execFileAsync(gitBin, ['reset', '--hard', `origin/${targetBranch}`], { cwd: workDir }).catch(() => undefined);
await execFileAsync(gitBin, ['read-tree', '--reset', '-u', commitSha], { cwd: workDir });
await execFileAsync(gitBin, ['add', '-A'], { cwd: workDir });
const { stdout } = await execFileAsync(gitBin, ['status', '--porcelain'], { cwd: workDir });
if (!stdout.trim()) {
return;
}
await execFileAsync(gitBin, ['commit', '--allow-empty', '-m', `${repository} release promotion snapshot`], { cwd: workDir });
}
private async resetPromotionWorktree(gitBin: string, workDir: string) { private async resetPromotionWorktree(gitBin: string, workDir: string) {
await execFileAsync(gitBin, ['merge', '--abort'], { cwd: workDir }).catch(() => undefined); await execFileAsync(gitBin, ['merge', '--abort'], { cwd: workDir }).catch(() => undefined);
await execFileAsync(gitBin, ['rebase', '--abort'], { cwd: workDir }).catch(() => undefined); await execFileAsync(gitBin, ['rebase', '--abort'], { cwd: workDir }).catch(() => undefined);