Skip to content

Commit 9867eba

Browse files
committed
fix: prune stale remote ref for self-hosted runners
1 parent ff0beed commit 9867eba

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

dist/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ function splitLines(multilineString) {
101101
}
102102
function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff) {
103103
return __awaiter(this, void 0, void 0, function* () {
104+
// For self-hosted runners the repository state persists between runs.
105+
// This prunes the stale remote ref when the pull request branch was
106+
// deleted after being merged or closed. Without this the push using
107+
// '--force-with-lease' fails due to "stale info."
108+
// https://github.com/peter-evans/create-pull-request/issues/633
109+
yield git.exec(['remote', 'prune', 'origin']);
104110
// Get the working base.
105111
// When a ref, it may or may not be the actual base.
106112
// When a commit, we must rebase onto the actual base.

src/create-or-update-branch.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ export async function createOrUpdateBranch(
9393
branchRemoteName: string,
9494
signoff: boolean
9595
): Promise<CreateOrUpdateBranchResult> {
96+
// For self-hosted runners the repository state persists between runs.
97+
// This prunes the stale remote ref when the pull request branch was
98+
// deleted after being merged or closed. Without this the push using
99+
// '--force-with-lease' fails due to "stale info."
100+
// https://github.com/peter-evans/create-pull-request/issues/633
101+
await git.exec(['remote', 'prune', 'origin'])
102+
96103
// Get the working base.
97104
// When a ref, it may or may not be the actual base.
98105
// When a commit, we must rebase onto the actual base.

0 commit comments

Comments
 (0)