This commit is contained in:
@@ -645,8 +645,22 @@ export class AppsService {
|
||||
const normalized = message.toLowerCase();
|
||||
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');
|
||||
await fs.mkdir(workRoot, { recursive: true });
|
||||
const mergeOptions = [
|
||||
'-c',
|
||||
`user.name=${gitUserName}`,
|
||||
'-c',
|
||||
`user.email=${gitUserEmail}`,
|
||||
];
|
||||
|
||||
for (const [repository, commitSha] of byRepository) {
|
||||
const workDir = path.join(workRoot, `${sanitizeImageName(repository)}-${Date.now()}`);
|
||||
@@ -669,6 +683,17 @@ export class AppsService {
|
||||
targetBranch,
|
||||
], { 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);
|
||||
if (targetExists) {
|
||||
await execFileAsync(gitBin, [
|
||||
@@ -679,6 +704,7 @@ export class AppsService {
|
||||
], { cwd: workDir });
|
||||
try {
|
||||
await execFileAsync(gitBin, [
|
||||
...mergeOptions,
|
||||
'merge',
|
||||
'--ff-only',
|
||||
commitSha,
|
||||
@@ -689,6 +715,7 @@ export class AppsService {
|
||||
throw error;
|
||||
}
|
||||
await execFileAsync(gitBin, [
|
||||
...mergeOptions,
|
||||
'merge',
|
||||
'--allow-unrelated-histories',
|
||||
'--no-ff',
|
||||
|
||||
Reference in New Issue
Block a user