paginate app operations and refine runtime settings layout
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -669,8 +669,6 @@ export class AppsService {
|
|||||||
targetBranch,
|
targetBranch,
|
||||||
], { cwd: workDir }).catch(() => undefined);
|
], { cwd: workDir }).catch(() => undefined);
|
||||||
|
|
||||||
const pushArgs: string[] = ['push', 'origin', `HEAD:refs/heads/${targetBranch}`];
|
|
||||||
|
|
||||||
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,7 +677,6 @@ export class AppsService {
|
|||||||
targetBranch,
|
targetBranch,
|
||||||
`origin/${targetBranch}`,
|
`origin/${targetBranch}`,
|
||||||
], { cwd: workDir });
|
], { cwd: workDir });
|
||||||
let forcePush = false;
|
|
||||||
try {
|
try {
|
||||||
await execFileAsync(gitBin, [
|
await execFileAsync(gitBin, [
|
||||||
'merge',
|
'merge',
|
||||||
@@ -691,17 +688,10 @@ export class AppsService {
|
|||||||
if (!isUnrelatedHistoryError(message)) {
|
if (!isUnrelatedHistoryError(message)) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
forcePush = true;
|
throw new BadRequestException(
|
||||||
await execFileAsync(gitBin, [
|
`${repository} release 브랜치 승격 실패: ${message}.` +
|
||||||
'checkout',
|
' release 브랜치가 다른 시작점 히스토리를 가지고 있어 fast-forward로 병합할 수 없습니다.',
|
||||||
'-B',
|
);
|
||||||
targetBranch,
|
|
||||||
commitSha,
|
|
||||||
], { cwd: workDir });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forcePush) {
|
|
||||||
pushArgs.splice(0, pushArgs.length, 'push', '--force-with-lease', 'origin', `HEAD:refs/heads/${targetBranch}`);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await execFileAsync(gitBin, [
|
await execFileAsync(gitBin, [
|
||||||
@@ -712,7 +702,11 @@ export class AppsService {
|
|||||||
], { cwd: workDir });
|
], { cwd: workDir });
|
||||||
}
|
}
|
||||||
|
|
||||||
await execFileAsync(gitBin, pushArgs, { cwd: workDir });
|
await execFileAsync(gitBin, [
|
||||||
|
'push',
|
||||||
|
'origin',
|
||||||
|
`HEAD:refs/heads/${targetBranch}`,
|
||||||
|
], { cwd: workDir });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : 'Unknown git promotion failure';
|
const message = error instanceof Error ? error.message : 'Unknown git promotion failure';
|
||||||
throw new BadRequestException(`${repository} release 브랜치 승격 실패: ${message}`);
|
throw new BadRequestException(`${repository} release 브랜치 승격 실패: ${message}`);
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ export class GiteaService {
|
|||||||
await this.createDefaultBranches(repo.owner.login, repo.name, repo.default_branch, body);
|
await this.createDefaultBranches(repo.owner.login, repo.name, repo.default_branch, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.setDefaultBranch(repo.owner.login, repo.name, 'develop');
|
||||||
|
|
||||||
if (body.createReleaseBranch !== false) {
|
if (body.createReleaseBranch !== false) {
|
||||||
await this.protectReleaseBranch(repo.owner.login, repo.name);
|
await this.protectReleaseBranch(repo.owner.login, repo.name);
|
||||||
}
|
}
|
||||||
@@ -194,6 +196,8 @@ export class GiteaService {
|
|||||||
await this.createDefaultBranches(org, repo.name, repo.default_branch, body);
|
await this.createDefaultBranches(org, repo.name, repo.default_branch, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.setDefaultBranch(org, repo.name, 'develop');
|
||||||
|
|
||||||
if (body.createReleaseBranch !== false) {
|
if (body.createReleaseBranch !== false) {
|
||||||
await this.protectReleaseBranch(org, repo.name);
|
await this.protectReleaseBranch(org, repo.name);
|
||||||
}
|
}
|
||||||
@@ -201,6 +205,22 @@ export class GiteaService {
|
|||||||
return { repo: mapRepo(repo), branches: await this.listBranches(org, repo.name) };
|
return { repo: mapRepo(repo), branches: await this.listBranches(org, repo.name) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async setDefaultBranch(owner: string, repo: string, branch: string) {
|
||||||
|
const branches = await this.listBranches(owner, repo);
|
||||||
|
const hasBranch = Array.isArray(branches.branches) && branches.branches.some((item) => {
|
||||||
|
return typeof item === 'object' && item && 'name' in item && item.name === branch;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!hasBranch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.request(`/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify({ default_branch: branch }),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async createUserSshKey(username: string, body: { title: string; key: string }) {
|
async createUserSshKey(username: string, body: { title: string; key: string }) {
|
||||||
this.assertToken();
|
this.assertToken();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user