From de98022e2c03e76e0c431d2a5091222f8257a859 Mon Sep 17 00:00:00 2001 From: chyoo Date: Tue, 7 Jul 2026 18:11:42 +0900 Subject: [PATCH] resolve release promotion unrelated-history conflicts by taking source side --- src/apps/apps.service.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/apps/apps.service.ts b/src/apps/apps.service.ts index 2a5e26b..074f57c 100644 --- a/src/apps/apps.service.ts +++ b/src/apps/apps.service.ts @@ -702,6 +702,7 @@ export class AppsService { targetBranch, `origin/${targetBranch}`, ], { cwd: workDir }); + await this.resetPromotionWorktree(gitBin, workDir); try { await execFileAsync(gitBin, [ ...mergeOptions, @@ -715,6 +716,7 @@ export class AppsService { throw error; } try { + await this.resetPromotionWorktree(gitBin, workDir); await execFileAsync(gitBin, [ ...mergeOptions, 'merge', @@ -757,6 +759,7 @@ export class AppsService { commitSha: string, repository: string, ) { + await this.resetPromotionWorktree(gitBin, workDir); await execFileAsync(gitBin, [ ...mergeOptions, 'merge', @@ -771,6 +774,13 @@ export class AppsService { await execFileAsync(gitBin, ['commit', '--allow-empty', '-m', `${repository} release promotion merge`], { cwd: workDir }); } + private async resetPromotionWorktree(gitBin: string, workDir: string) { + await execFileAsync(gitBin, ['merge', '--abort'], { cwd: workDir }).catch(() => undefined); + await execFileAsync(gitBin, ['rebase', '--abort'], { cwd: workDir }).catch(() => undefined); + await execFileAsync(gitBin, ['reset', '--hard'], { cwd: workDir }).catch(() => undefined); + await execFileAsync(gitBin, ['clean', '-fd'], { cwd: workDir }).catch(() => undefined); + } + private getHttpCloneUrl(repository: string) { return `${this.configService .get('GITEA_BASE_URL', 'http://localhost:3000')