Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: used merge-upstream to sync fork & upstream #6504

Merged
merged 9 commits into from
Nov 15, 2023
34 changes: 23 additions & 11 deletions packages/decap-cms-backend-github/src/implementation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,31 @@ export default class GitHub implements Implementation {
return Promise.resolve();
}

if (!(await this.forkExists({ token }))) {
// If a fork exists merge it with upstream
// otherwise create a new fork.
if (await this.forkExists({ token })) {
return fetch(`${this.apiRoot}/repos/${userData.login}/${this.originRepo}/merge-upstream`, {
method: 'POST',
headers: {
Authorization: `token ${token}`,
},
body: JSON.stringify({
branch: this.branch,
}),
});
} else {
await getPermissionToFork();
}

const fork = await fetch(`${this.apiRoot}/repos/${this.originRepo}/forks`, {
method: 'POST',
headers: {
Authorization: `token ${token}`,
},
}).then(res => res.json());
this.useOpenAuthoring = true;
this.repo = fork.full_name;
return this.pollUntilForkExists({ repo: fork.full_name, token });
const fork = await fetch(`${this.apiRoot}/repos/${this.originRepo}/forks`, {
method: 'POST',
headers: {
Authorization: `token ${token}`,
},
}).then(res => res.json());
this.useOpenAuthoring = true;
this.repo = fork.full_name;
return this.pollUntilForkExists({ repo: fork.full_name, token });
}
}

async authenticate(state: Credentials) {
Expand Down
Loading