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

V6 #2717

Merged
merged 12 commits into from
Jan 31, 2024
Prev Previous commit
Next Next commit
build: update dist
peter-evans committed Jan 31, 2024
commit c8e25cd056fd6c72f8d2bf0786ec121ff987580a
13 changes: 9 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -363,9 +363,14 @@ function createPullRequest(inputs) {
if (inputs.pushToFork) {
// Check if the supplied fork is really a fork of the base
core.info(`Checking if '${branchRepository}' is a fork of '${baseRemote.repository}'`);
const parentRepository = yield githubHelper.getRepositoryParent(branchRepository);
if (parentRepository != baseRemote.repository) {
throw new Error(`Repository '${branchRepository}' is not a fork of '${baseRemote.repository}'. Unable to continue.`);
const baseParentRepository = yield githubHelper.getRepositoryParent(baseRemote.repository);
const branchParentRepository = yield githubHelper.getRepositoryParent(branchRepository);
if (branchParentRepository == null) {
throw new Error(`Repository '${branchRepository}' is not a fork. Unable to continue.`);
}
if (branchParentRepository != baseRemote.repository &&
baseParentRepository != branchParentRepository) {
throw new Error(`Repository '${branchRepository}' is not a fork of '${baseRemote.repository}', nor are they siblings. Unable to continue.`);
}
// Add a remote for the fork
const remoteUrl = utils.getRemoteUrl(baseRemote.protocol, baseRemote.hostname, branchRepository);
@@ -1104,7 +1109,7 @@ class GitHubHelper {
return __awaiter(this, void 0, void 0, function* () {
const { data: headRepo } = yield this.octokit.rest.repos.get(Object.assign({}, this.parseRepository(headRepository)));
if (!headRepo.parent) {
throw new Error(`Repository '${headRepository}' is not a fork. Unable to continue.`);
return null;
}
return headRepo.parent.full_name;
});