-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Required signatures on protected branches #1039
Conversation
Preview required commit signatures for Protected Branches API https://developer.github.com/changes/2018-02-22-protected-branches-required-signatures/ Signed-off-by: Daniel Nilsson <[email protected]>
Signed-off-by: Daniel Nilsson <[email protected]>
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, @danijeel!
I have a few requested changes and a couple open questions.
github/repos.go
Outdated
@@ -698,6 +698,13 @@ type DismissalRestrictionsRequest struct { | |||
Teams *[]string `json:"teams,omitempty"` | |||
} | |||
|
|||
// SignaturesProtectedBranch represents the protection status of a individual branch. |
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.
s/a individual/an individual/
github/repos.go
Outdated
type SignaturesProtectedBranch struct { | ||
URL *string `json:"url,omitempty"` | ||
// Commits pushed to matching branches must have verified signatures. | ||
Enabled bool `json:"strict"` |
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.
Why not
Strict *bool `json:"strict,omitempty"`
?
github/repos.go
Outdated
@@ -850,6 +857,67 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, | |||
return s.client.Do(ctx, req, nil) | |||
} | |||
|
|||
// GetSignaturesProtectedBranch get required signatures of protected branch |
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.
s/get /gets /
s/branch/branch./
github/repos.go
Outdated
return p, resp, nil | ||
} | ||
|
||
// AddSignatureProtectedBranch Require signed commits to a protected branch. |
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.
I'm wondering if this should be renamed... I'm not even happy with the working on the GitHub API docs themselves.
From the description at the provided URL, it sounds like this endpoint is used to require signatures on protected branches. So how about this:
`// RequireSignaturesOnProtectedBranch makes signed commits required on a protected branch.```
github/repos.go
Outdated
return r, resp, err | ||
} | ||
|
||
// RemoveSignatureProtectedBranch removes required signed commits on a given branch. |
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.
Maybe OptionalSignaturesOnProtectedBranch
?
Signed-off-by: Daniel Nilsson <[email protected]>
Thank you for the review and feedback @gmlewis! I've updated the comments you mention above. |
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, @danijeel!
One more small tweak and then LGTM.
Awaiting second LGTM before merging.
github/repos.go
Outdated
type SignaturesProtectedBranch struct { | ||
URL *string `json:"url,omitempty"` | ||
// Commits pushed to matching branches must have verified signatures. | ||
Enabled bool `json:"strict"` | ||
Enabled bool `json:"strict,omitempty"` |
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.
This still needs *bool
.
Signed-off-by: Daniel Nilsson <[email protected]>
Ah, yes. thank you @gmlewis. Could you please review the test cases if they make sense? |
on SignaturesProtectedBranch Signed-off-by: Daniel Nilsson <[email protected]>
Signed-off-by: Daniel Nilsson <[email protected]>
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.
LGTM thanks for your contribution 👍
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.
Just a few minor changes, please.
Thank you, @danijeel!
github/repos_test.go
Outdated
@@ -1066,13 +1066,13 @@ func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) { | |||
}) | |||
|
|||
signature, _, err := client.Repositories.GetSignaturesProtectedBranch(context.Background(), "o", "r", "b") | |||
|
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.
Please delete this blank line, as we attempt to keep the error checking code tightly bound to the section of code that created it.
github/repos_test.go
Outdated
if err != nil { | ||
t.Errorf("Repositories.GetSignaturesProtectedBranch returned error: %v", err) | ||
} | ||
|
||
want := &SignaturesProtectedBranch{ | ||
URL: String("/repos/o/r/branches/b/protection/required_signatures"), | ||
Enabled: false, | ||
URL: String("/repos/o/r/branches/b/protection/required_signatures"), |
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.
Please add back your Enabled: Bool(false),
line here and below.
github/repos_test.go
Outdated
@@ -1096,9 +1096,9 @@ func TestRepositoriesService_AddSignatureProtectedBranch(t *testing.T) { | |||
} | |||
|
|||
want := &SignaturesProtectedBranch{ | |||
URL: String("/repos/o/r/branches/b/protection/required_signatures"), | |||
Enabled: false, | |||
URL: String("/repos/o/r/branches/b/protection/required_signatures"), |
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.
Please add back your Enabled: Bool(false),
line here.
Signed-off-by: Daniel Nilsson <[email protected]>
github/repos_test.go
Outdated
} | ||
} | ||
|
||
func TestRepositoriesService_RemoveSignatureProtectedBranch(t *testing.T) { |
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.
s/RemoveSignature/OptionalSignaturesOn/
github/repos.go
Outdated
type SignaturesProtectedBranch struct { | ||
URL *string `json:"url,omitempty"` | ||
// Commits pushed to matching branches must have verified signatures. | ||
Enabled *bool `json:"strict,omitempty"` |
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.
s/strict/enabled/
Signed-off-by: Daniel Nilsson <[email protected]>
Signed-off-by: Daniel Nilsson <[email protected]>
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, @danijeel and @gauntface!
LGTM.
Merging since we already have second LGTM.
Added support for the preview required commit signatures for Protected Branches API.
https://developer.github.com/changes/2018-02-22-protected-branches-required-signatures/
This solves: #902