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

Required signatures on protected branches #1039

Merged
merged 9 commits into from
Nov 9, 2018

Conversation

dlnilsson
Copy link
Contributor

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

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Oct 29, 2018
Copy link
Collaborator

@gmlewis gmlewis 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, @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.
Copy link
Collaborator

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"`
Copy link
Collaborator

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
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe OptionalSignaturesOnProtectedBranch ?

@dlnilsson
Copy link
Contributor Author

Thank you for the review and feedback @gmlewis! I've updated the comments you mention above.

Copy link
Collaborator

@gmlewis gmlewis 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, @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"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This still needs *bool.

@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. and removed question labels Nov 2, 2018
@gmlewis gmlewis requested a review from gauntface November 2, 2018 10:52
Signed-off-by: Daniel Nilsson <[email protected]>
@dlnilsson
Copy link
Contributor Author

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]>
Copy link
Contributor

@gauntface gauntface left a 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 👍

Copy link
Collaborator

@gmlewis gmlewis left a 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!

@@ -1066,13 +1066,13 @@ func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) {
})

signature, _, err := client.Repositories.GetSignaturesProtectedBranch(context.Background(), "o", "r", "b")

Copy link
Collaborator

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.

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"),
Copy link
Collaborator

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.

@@ -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"),
Copy link
Collaborator

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]>
}
}

func TestRepositoriesService_RemoveSignatureProtectedBranch(t *testing.T) {
Copy link
Collaborator

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"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/strict/enabled/

Copy link
Collaborator

@gmlewis gmlewis 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, @danijeel and @gauntface!
LGTM.
Merging since we already have second LGTM.

@gmlewis gmlewis merged commit 99760a1 into google:master Nov 9, 2018
@dlnilsson dlnilsson deleted the required_signatures branch January 3, 2019 18:36
n1lesh pushed a commit to n1lesh/go-github that referenced this pull request Oct 2, 2020
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants