Skip to content

Commit fec0e71

Browse files
Copilotalexr00
andcommitted
Set branch.push config to enable git push without arguments for fork PRs
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 5f40795 commit fec0e71

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/github/pullRequestGitHelper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export class PullRequestGitHelper {
7474
await repository.checkout(localBranchName);
7575
// set remote tracking branch for the local branch
7676
await repository.setBranchUpstream(localBranchName, trackedBranchName);
77+
// set push destination to allow `git push` without arguments even when branch names differ
78+
await repository.setConfig(`branch.${localBranchName}.push`, `refs/heads/${pullRequest.head.ref}`);
7779
await PullRequestGitHelper.associateBranchWithPullRequest(repository, pullRequest, localBranchName);
7880
}
7981

src/test/github/pullRequestGitHelper.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ describe('PullRequestGitHelper', function () {
188188
},
189189
});
190190
assert.strictEqual(await repository.getConfig('branch.pr/me/100.github-pr-owner-number'), 'owner#name#100');
191+
assert.strictEqual(await repository.getConfig('branch.pr/me/100.push'), 'refs/heads/my-branch');
191192
});
192193
});
193194
});

0 commit comments

Comments
 (0)