handle unrelated history promotion fallback
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-07 18:05:13 +09:00
parent 85cd5ebcd5
commit 89b0b7d15c
+27
View File
@@ -645,8 +645,22 @@ export class AppsService {
const normalized = message.toLowerCase(); const normalized = message.toLowerCase();
return normalized.includes('refusing to merge unrelated histories') || normalized.includes('not possible to fast-forward'); return normalized.includes('refusing to merge unrelated histories') || normalized.includes('not possible to fast-forward');
}; };
const gitUserName = this.configService.get<string>(
'GIT_USER_NAME',
'Autonomy Studio Bot',
);
const gitUserEmail = this.configService.get<string>(
'GIT_USER_EMAIL',
'studio-ci@autonomystudio.local',
);
const workRoot = path.join(os.tmpdir(), 'studio-admin-release-promotions'); const workRoot = path.join(os.tmpdir(), 'studio-admin-release-promotions');
await fs.mkdir(workRoot, { recursive: true }); await fs.mkdir(workRoot, { recursive: true });
const mergeOptions = [
'-c',
`user.name=${gitUserName}`,
'-c',
`user.email=${gitUserEmail}`,
];
for (const [repository, commitSha] of byRepository) { for (const [repository, commitSha] of byRepository) {
const workDir = path.join(workRoot, `${sanitizeImageName(repository)}-${Date.now()}`); const workDir = path.join(workRoot, `${sanitizeImageName(repository)}-${Date.now()}`);
@@ -669,6 +683,17 @@ export class AppsService {
targetBranch, targetBranch,
], { cwd: workDir }).catch(() => undefined); ], { cwd: workDir }).catch(() => undefined);
await execFileAsync(gitBin, [
'config',
'user.name',
gitUserName,
], { cwd: workDir });
await execFileAsync(gitBin, [
'config',
'user.email',
gitUserEmail,
], { cwd: workDir });
const targetExists = await gitRefExists(workDir, `refs/remotes/origin/${targetBranch}`, gitBin); const targetExists = await gitRefExists(workDir, `refs/remotes/origin/${targetBranch}`, gitBin);
if (targetExists) { if (targetExists) {
await execFileAsync(gitBin, [ await execFileAsync(gitBin, [
@@ -679,6 +704,7 @@ export class AppsService {
], { cwd: workDir }); ], { cwd: workDir });
try { try {
await execFileAsync(gitBin, [ await execFileAsync(gitBin, [
...mergeOptions,
'merge', 'merge',
'--ff-only', '--ff-only',
commitSha, commitSha,
@@ -689,6 +715,7 @@ export class AppsService {
throw error; throw error;
} }
await execFileAsync(gitBin, [ await execFileAsync(gitBin, [
...mergeOptions,
'merge', 'merge',
'--allow-unrelated-histories', '--allow-unrelated-histories',
'--no-ff', '--no-ff',