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

gerritapi: Support ListCommitsOptions in ListCommits.
dmitshur committed 7 years ago commit cdaf586f51586989634627a90d84d3731690483d
Collapse all
gerritapi/gerritapi.go
@@ -135,21 +135,36 @@ func (s service) ListCommits(ctx context.Context, _ string, id uint64, opt *chan
		return nil, err
	}
	if change.Status == "DRAFT" {
		return nil, os.ErrNotExist
	}
	commits := make([]changes.Commit, len(change.Revisions))
	for sha, r := range change.Revisions {
		commits[r.Number-1] = changes.Commit{
			SHA:     sha,
	switch opt {
	case nil:
		commits := make([]changes.Commit, len(change.Revisions))
		for sha, r := range change.Revisions {
			commits[r.Number-1] = changes.Commit{
				SHA:     sha,
				Message: fmt.Sprintf("Patch Set %d", r.Number),
				// TODO: r.Uploader and r.Created describe the committer, not author.
				Author:     s.gerritUser(r.Uploader),
				AuthorTime: time.Time(r.Created),
			}
		}
		return commits, nil
	default:
		r, ok := change.Revisions[opt.Commit]
		if !ok {
			return nil, os.ErrNotExist
		}
		return []changes.Commit{{
			SHA:     opt.Commit,
			Message: fmt.Sprintf("Patch Set %d", r.Number),
			// TODO: r.Uploader and r.Created describe the committer, not author.
			Author:     s.gerritUser(r.Uploader),
			AuthorTime: time.Time(r.Created),
		}
		}}, nil
	}
	return commits, nil
}

func (s service) GetDiff(ctx context.Context, _ string, id uint64, opt *changes.ListCommitsOptions) ([]byte, error) {
	diff, _, err := s.cl.Changes.GetPatch(fmt.Sprint(id), "current", &gerrit.PatchOptions{
		Path: "src", // TODO.