Skip to content

Improve the SubmitRecord structure #168

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
24 changes: 24 additions & 0 deletions changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,40 @@ type TopicInput struct {
Topic string `json:"topic,omitempty"`
}

type Account struct {
AccountId int `json:"_account_id"`
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
Tags []string `json:"tags,omitempty"`
}
Copy link
Owner

Choose a reason for hiding this comment

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

This is not needed, as we need an AccountInfo type

Copy link
Author

Choose a reason for hiding this comment

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

In a new commit I have modified


type SubmitRecordLabel struct {
Label string `json:"label"`
Status string `json:"status"`
AppliedBy *Account `json:"applied_by,omitempty"`
}

// SubmitRecord entity describes results from a submit_rule.
type SubmitRecord struct {
Copy link
Owner

Choose a reason for hiding this comment

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

According to the docs, SubmitRecordInfo (https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-record-info) and SubmitRecord (https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#submit-record) are different types. I would prefer if we create two different types as well.

Copy link
Author

Choose a reason for hiding this comment

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

In a new commit I have modified

RuleName string `json:"rule_name"`
Copy link
Owner

Choose a reason for hiding this comment

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

Please extend the ,omitempty tags

Copy link
Author

Choose a reason for hiding this comment

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

In a new commit I have modified

Status string `json:"status"`
Labels []SubmitRecordLabel `json:"labels"`
Ok map[string]map[string]AccountInfo `json:"ok,omitempty"`
Reject map[string]map[string]AccountInfo `json:"reject,omitempty"`
Need map[string]interface{} `json:"need,omitempty"`
May map[string]map[string]AccountInfo `json:"may,omitempty"`
Impossible map[string]interface{} `json:"impossible,omitempty"`
Requirements []Requirement `json:"requirements,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}

type Requirement struct {
Status string `json:"status"`
FallbackText string `json:"fallback_text"`
Type string `json:"type"`
}

// SubmitInput entity contains information for submitting a change.
type SubmitInput struct {
OnBehalfOf string `json:"on_behalf_of,omitempty"`
Expand Down Expand Up @@ -472,6 +495,7 @@ type ChangeInfo struct {
CherryPickOfPatchSet int `json:"cherry_pick_of_patch_set,omitempty"`
ContainsGitConflicts bool `json:"contains_git_conflicts,omitempty"`
BaseChange string `json:"base_change,omitempty"`
SubmitRecords []SubmitRecord `json:"submit_records"`
}

// LabelInfo entity contains information about a label on a change, always corresponding to the current patch set.
Expand Down