Skip to content

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

Merged
merged 1 commit into from
Apr 18, 2017
Merged

Conversation

bobeagan
Copy link
Contributor

Add missing loki-preview accept header for branch protection methods
This needs to wait for #562 to merge because I am a bad lazy person

@@ -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));
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the last commit applies to this PR, please direct that feedback to #562 where @Nyholm specifically requested that behavior.

Copy link
Contributor

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.

Copy link
Collaborator

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?

Copy link
Contributor

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.

Copy link
Collaborator

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.

@Nyholm
Copy link
Collaborator

Nyholm commented Apr 18, 2017

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.

@Nyholm
Copy link
Collaborator

Nyholm commented Apr 18, 2017

You have to rebase this PR and solve the conflicts.

@bobeagan bobeagan force-pushed the protection-configure branch from 6f5577d to adecb25 Compare April 18, 2017 16:53
@bobeagan
Copy link
Contributor Author

@Nyholm sorry about that, i hoped github would magically handle that for me when the other branch got merged, it has been rebased

Copy link
Collaborator

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

@Nyholm Nyholm merged commit 717bfa8 into KnpLabs:master Apr 18, 2017
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