-
-
Notifications
You must be signed in to change notification settings - Fork 599
Protection configure #568
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
Protection configure #568
Conversation
lib/Github/Api/PullRequest.php
Outdated
@@ -163,6 +164,10 @@ public function merge($username, $repository, $id, $message, $sha, $mergeMethod | |||
$mergeMethod = $mergeMethod ? 'squash' : 'merge'; | |||
} | |||
|
|||
if (!in_array($mergeMethod, array('merge', 'squash', 'rebase'), true)) { | |||
throw new InvalidArgumentException(sprintf('"$mergeMethod" must be one of ["merge", "squash", "rebase"] ("%s" given).', $mergeMethod)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems silly to hard code this. Let GitHub's API decide what is or isn't a valid option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, my comment still stands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to fail early. Since the API client knows that the request is going to fail, why now throw an exception right away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub reserve the right to add new merge methods, so the client does not know this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We argue about how smart/helpful or ("helpful") the client should be.
My opinion is not more valid than any other, but will I approve this because of consistency. We throw InvalidArugmentException
when we know the API is going to return a fail in Review::create, CurrentUser/Emails::add, Issue/Labels::add. And as mentioned before; on plenty of places we silently correct wrong input parameters.
This PR only adds a traits and configure method to the Protection API. The diff is unfair. Try to not put unrelated commits into PRs in the future. |
You have to rebase this PR and solve the conflicts. |
6f5577d
to
adecb25
Compare
@Nyholm sorry about that, i hoped github would magically handle that for me when the other branch got merged, it has been rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Add missing loki-preview accept header for branch protection methods
This needs to wait for #562 to merge because I am a
badlazy person