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

apply gofmt, add new fields to ReviewInput #123

Merged
merged 3 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,22 @@ type ReviewerInput struct {

// ReviewInput entity contains information for adding a review to a revision.
type ReviewInput struct {
Message string `json:"message,omitempty"`
Tag string `json:"tag,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Comments map[string][]CommentInput `json:"comments,omitempty"`
RobotComments map[string][]RobotCommentInput `json:"robot_comments,omitempty"`
StrictLabels bool `json:"strict_labels,omitempty"`
Drafts string `json:"drafts,omitempty"`
Notify string `json:"notify,omitempty"`
OmitDuplicateComments bool `json:"omit_duplicate_comments,omitempty"`
OnBehalfOf string `json:"on_behalf_of,omitempty"`
Message string `json:"message,omitempty"`
Tag string `json:"tag,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Comments map[string][]CommentInput `json:"comments,omitempty"`
RobotComments map[string][]RobotCommentInput `json:"robot_comments,omitempty"`
StrictLabels bool `json:"strict_labels,omitempty"`
Drafts string `json:"drafts,omitempty"`
Notify string `json:"notify,omitempty"`
OmitDuplicateComments bool `json:"omit_duplicate_comments,omitempty"`
OnBehalfOf string `json:"on_behalf_of,omitempty"`
Reviewers []ReviewerInput `json:"reviewers,omitempty"`
Ready bool `json:"ready,omitempty"`
WorkInProgress bool `json:"work_in_progress,omitempty"`
AddToAttentionSet []AttentionSetInput `json:"add_to_attention_set,omitempty"`
RemoveFromAttentionSet []AttentionSetInput `json:"remove_from_attention_set,omitempty"`
IgnoreAutomaticAttentionSetRules bool `json:"ignore_automatic_attention_set_rules,omitempty"`
}

// RelatedChangeAndCommitInfo entity contains information about a related change and commit.
Expand Down Expand Up @@ -348,7 +354,8 @@ type FixReplacementInfo struct {
Replacement string `json:"replacement,omitempty"`
}

// AttentionSetInfo entity contains details of users that are in the attention set.
// AttentionSetInfo entity contains details of users that are in the attention set.
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-info
type AttentionSetInfo struct {
// AccountInfo entity.
Expand All @@ -359,6 +366,19 @@ type AttentionSetInfo struct {
Reason string `json:"reason"`
}

type RecipientType string
Copy link
Owner

Choose a reason for hiding this comment

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

As far as I can see, other enum-type strings, we keep as stings.
We don't validate enums here.

What do you think about keeping this as string?
Or maybe: What was the rational behind adding this as its own type?

Copy link
Owner

Choose a reason for hiding this comment

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

Alternatively: Adding https://gerrit-review.googlesource.com/Documentation/user-notify.html#recipient-types as the doc link here might help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong feeling here. I just personally go for named types when it comes to enums; otherwise it's easy to typo a string and have code silently fail. You can't add the named type later on v1+, because that's technically a breaking change, which is why I added it now. I didn't add the constants because those can always be added later.

I don't mind either way though, so I'm OK with deleting if you disagree. Alternatively, happy for you to apply the suggested change and merge.

Copy link
Owner

Choose a reason for hiding this comment

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

I will go with the named type. Thanks @mvdan!

andygrunwald marked this conversation as resolved.
Show resolved Hide resolved

// AttentionSetInput entity contains details for adding users to the attention
// set and removing them from it.
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-input
type AttentionSetInput struct {
User string `json:"user,omitempty"`
Reason string `json:"reason"`
Notify string `json:"notify,omitempty"`
NotifyDetails map[RecipientType]NotifyInfo `json:"notify_details,omitempty"`
}

// DiffIntralineInfo entity contains information about intraline edits in a file.
//
// The information consists of a list of <skip length, mark length> pairs,
Expand Down
3 changes: 1 addition & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The services of a client divide the API into logical chunks and correspond to
the structure of the Gerrit API documentation at
https://gerrit-review.googlesource.com/Documentation/rest-api.html#_endpoints.

Authentication
# Authentication

The go-gerrit library supports various methods to support the authentication.
This methods are combined in the AuthenticationService that is available at client.Authentication.
Expand Down Expand Up @@ -63,6 +63,5 @@ With this you can authenticate with HTTP Basic like this:
Additionally when creating a new client, pass an http.Client that supports further actions for you.
For more information regarding authentication have a look at the Gerrit documentation:
https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

*/
package gerrit