mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 13:21:00 +00:00
fix(github): duplicate release pr when process is stopped at wrong moment (#236)
In a timing issue, the release pull request may be created but the releaser-pleaser labels not added. On the next run releaser-pleaser then creates a second release pull request. We try to reduce the chance of this happening by checking the context cancellation at the top, and if its not cancelled we run both API requests without passing along any cancellations from the parent context. Closes #215
This commit is contained in:
parent
48b1894cac
commit
d259921215
1 changed files with 7 additions and 1 deletions
|
|
@ -296,6 +296,13 @@ func (g *GitHub) PullRequestForBranch(ctx context.Context, branch string) (*rele
|
|||
}
|
||||
|
||||
func (g *GitHub) CreatePullRequest(ctx context.Context, pr *releasepr.ReleasePullRequest) error {
|
||||
// If the Pull Request is created without the labels releaser-pleaser will create a new PR in the run. The user may merge both and have duplicate entries in the changelog.
|
||||
// We try to avoid this situation by checking for a cancelled context first, and then running both API calls without passing along any cancellations.
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
ctx = context.WithoutCancel(ctx)
|
||||
|
||||
ghPR, _, err := g.client.PullRequests.Create(
|
||||
ctx, g.options.Owner, g.options.Repo,
|
||||
&github.NewPullRequest{
|
||||
|
|
@ -309,7 +316,6 @@ func (g *GitHub) CreatePullRequest(ctx context.Context, pr *releasepr.ReleasePul
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO: String ID?
|
||||
pr.ID = ghPR.GetNumber()
|
||||
|
||||
err = g.SetPullRequestLabels(ctx, pr, []releasepr.Label{}, pr.Labels)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue