Skip to content

Commit

Permalink
Merge pull request #637 from peter-evans/prune-remote
Browse files Browse the repository at this point in the history
fix: prune stale remote ref for self-hosted runners
  • Loading branch information
peter-evans authored Nov 25, 2020
2 parents ff0beed + 9984f61 commit ce699aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ function createPullRequest(inputs) {
if (branchRemoteName == 'origin' && base == inputs.branch) {
throw new Error(`The 'base' and 'branch' for a pull request must be different branches. Unable to continue.`);
}
// For self-hosted runners the repository state persists between runs.
// This command prunes the stale remote ref when the pull request branch was
// deleted after being merged or closed. Without this the push using
// '--force-with-lease' fails due to "stale info."
// https://github.com/peter-evans/create-pull-request/issues/633
yield git.exec(['remote', 'prune', branchRemoteName]);
core.endGroup();
// Apply the branch suffix if set
if (inputs.branchSuffix) {
Expand Down
6 changes: 6 additions & 0 deletions src/create-pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
`The 'base' and 'branch' for a pull request must be different branches. Unable to continue.`
)
}
// For self-hosted runners the repository state persists between runs.
// This command prunes the stale remote ref when the pull request branch was
// deleted after being merged or closed. Without this the push using
// '--force-with-lease' fails due to "stale info."
// https://github.com/peter-evans/create-pull-request/issues/633
await git.exec(['remote', 'prune', branchRemoteName])
core.endGroup()

// Apply the branch suffix if set
Expand Down

0 comments on commit ce699aa

Please sign in to comment.