dmitri.shuralyov.com/service/change/...

gerritapi: Populate Change.Commits field.
dmitshur committed 7 years ago commit 382de3bdead9edba25a36da645446c084e517500
Collapse all
gerritapi/gerritapi.go
@@ -91,11 +91,11 @@ func (s service) Count(_ context.Context, repo string, opt changes.ListOptions)
	return 0, nil
}

func (s service) Get(ctx context.Context, _ string, id uint64) (changes.Change, error) {
	change, _, err := s.cl.Changes.GetChange(fmt.Sprint(id), &gerrit.ChangeOptions{
		AdditionalFields: []string{"DETAILED_ACCOUNTS"},
		AdditionalFields: []string{"DETAILED_ACCOUNTS", "ALL_REVISIONS"},
	})
	if err != nil {
		return changes.Change{}, err
	}
	if change.Status == "DRAFT" {
@@ -105,10 +105,11 @@ func (s service) Get(ctx context.Context, _ string, id uint64) (changes.Change,
		ID:        id,
		State:     state(change.Status),
		Title:     change.Subject,
		Author:    s.gerritUser(change.Owner),
		CreatedAt: time.Time(change.Created),
		Commits:   len(change.Revisions),
	}, nil
}

func state(status string) changes.State {
	switch status {