Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Do not send status update if user disable it #57

Merged
merged 1 commit into from
Mar 19, 2015

Conversation

sikachu
Copy link
Contributor

@sikachu sikachu commented Mar 18, 2015

We forgot to check if user has turned on the update_status flag or not before we sends a pending status to GitHub.

This commit includes refactoring, hopefully to cleanup the confusion on conditionals.

receive_pull_request({}, {
github_slug: "pbrisbin/foo",
commit_sha: "abc123",
state: "pending",
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be state: "error" to match the test description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed it but you commented the wrong one.

@sikachu sikachu force-pushed the ps-fix-update-status-disabled branch 2 times, most recently from 223dd3a to fd55ad0 Compare March 19, 2015 14:57
We forgot to check if user has turned on the `update_status` flag or not
before we sends a pending status to GitHub.

This commit includes refactoring, hopefully to cleanup the confusion on
conditionals.
@sikachu
Copy link
Contributor Author

sikachu commented Mar 19, 2015

This is ready for another look. I updated the code to hopefully make it cleaner, and also add more tests on those default response ... Ready for re-review!

update_status_skipped
end
when "error"
update_status_error
Copy link
Contributor

Choose a reason for hiding this comment

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

Goodbye cruel conditionals!

@iancanderson
Copy link
Contributor

LGTM

1 similar comment
@noahd1
Copy link
Contributor

noahd1 commented Mar 19, 2015

LGTM

end

def update_status_success
update_status("success", "Code Climate has analyzed this pull request.")
add_comment
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in love with having status mixed in with commenting, but it's a larger issue with this class in general (that it does two things). Commenting should go away soon, so I'm ok with this.

However -- I think we swap the order of these lines for now. We're not capturing both results in the response back (just the last one), but the PR one is the more important one right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. This class is doing too much.

I'm fine with the swap, but that means we're actually change the functionality of this (and its return value). Currently, we return the status of add comment only. Do you think we should swap it anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair. Perhaps a separate PR then is appropriate for this change. I think it's in scope however, because we're now capturing the result of these calls -- and the most important result is the one that comes back from posting a status to a PR (not the comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Let's do that swap in another PR. 🥚

sikachu added a commit that referenced this pull request Mar 19, 2015
Do not send PR status update if user disable it
@sikachu sikachu merged commit ab39f58 into master Mar 19, 2015
@sikachu sikachu deleted the ps-fix-update-status-disabled branch March 19, 2015 18:00
marshally added a commit that referenced this pull request Mar 20, 2015
…eady exists

Trello: https://trello.com/c/npDQ4rN3/103-record-response-from-sending-commit-status-instead-of-adding-comment-when-both-commit-status-and-comment-are-on
fixes: #57 (diff)

GithubPullRequests were mistakenly returning a false success code in the common
case where a comment is already present on the pull request being updated. We
should return a success instead.
marshally added a commit that referenced this pull request Mar 20, 2015
…eady exists

Trello: https://trello.com/c/npDQ4rN3/103-record-response-from-sending-commit-status-instead-of-adding-comment-when-both-commit-status-and-comment-are-on
fixes: #57 (diff)

GithubPullRequests were mistakenly returning a false success code in the common
case where a comment is already present on the pull request being updated. We
should return a success instead.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants