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

Avoid updating state on closed PRs #270

Merged

Conversation

derekjobst
Copy link
Contributor

Addresses #269

@derekjobst derekjobst marked this pull request as ready for review February 17, 2021 20:20
@derekjobst derekjobst changed the title Draft: Avoid updating state on closed PRs Avoid updating state on closed PRs Feb 17, 2021
pull/context.go Outdated
Comment on lines 68 to 69
// State returns the state of the pull request (open or closed)
State() string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is either open or closed is there an advantage to returning it as a string instead of implementing it as an IsClosed() or IsOpen() method?

Copy link
Contributor Author

@derekjobst derekjobst Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a bool seems like a better option. Changed.

I believe the values are limited to open and closed, although I thought I saw somewhere that merged was also an option. After looking again, this is the best enumeration of state values I've been able to find and it's just the two.


// IsClosed returns true when the state of the pull request is "closed"
IsClosed() bool

Copy link
Contributor Author

@derekjobst derekjobst Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps IsClosed is not necessary yet, but it felt right to add since open and closed are the two possible values (that I am aware of, right now).

@derekjobst derekjobst requested a review from bluekeyes March 4, 2021 00:06
@@ -88,6 +88,11 @@ func (b *Base) PostStatus(ctx context.Context, prctx pull.Context, client *githu
sha := prctx.HeadSHA()
base, _ := prctx.Branches()

if !prctx.IsOpen() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!IsOpen seemed better than IsClosed since there could be additional options added in the future. We are specifically looking to skip in all cases except when status is open, rather than just when it is closed.

@derekjobst derekjobst merged commit e63ccdb into develop Mar 4, 2021
@derekjobst derekjobst deleted the djobst/prevent-detail-page-status-updates-for-merged-prs branch March 4, 2021 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants