Skip to content

Commit

Permalink
feat: add submittable field for change info
Browse files Browse the repository at this point in the history
Change-Id: I116b354992b4d96ec1b94c8ae30236249d80b367
  • Loading branch information
wuguohua.5281 authored and andygrunwald committed Aug 16, 2019
1 parent 64931d2 commit 759bda1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ type ChangeInfo struct {
MoreChanges bool `json:"_more_changes,omitempty"`
Problems []ProblemInfo `json:"problems,omitempty"`
BaseChange string `json:"base_change,omitempty"`
Submittable bool `json:"submittable,omitempty"`
}

// LabelInfo entity contains information about a label on a change, always corresponding to the current patch set.
Expand Down
26 changes: 26 additions & 0 deletions changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@ func ExampleChangesService_QueryChanges() {
// Project: platform/art -> ART: Change return types of field access entrypoints -> https://android-review.googlesource.com/249244
}

func ExampleChangesService_QueryChanges_WithSubmittable() {
instance := "https://android-review.googlesource.com/"
client, err := gerrit.NewClient(instance, nil)
if err != nil {
panic(err)
}

opt := &gerrit.QueryChangeOptions{}
opt.Query = []string{
"change:249244",
}
opt.AdditionalFields = []string{"SUBMITTABLE"}

changes, _, err := client.Changes.QueryChanges(opt)
if err != nil {
panic(err)
}

for _, change := range *changes {
fmt.Printf("Project: %s -> %s -> %s%d, Ready to submit: %t\n", change.Project, change.Subject, instance, change.Number, change.Submittable)
}

// Output:
// Project: platform/art -> ART: Change return types of field access entrypoints -> https://android-review.googlesource.com/249244, Ready to submit: false
}

// Prior to fixing #18 this test would fail.
func ExampleChangesService_QueryChanges_withSymbols() {
instance := "https://android-review.googlesource.com/"
Expand Down

0 comments on commit 759bda1

Please sign in to comment.