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

Rename ListCommitsOptions to GetDiffOptions.
dmitshur committed 6 years ago commit 289d31ac2173d2e8c99ba4829e17169c23d05aa2
Collapse all
changes.go
@@ -19,11 +19,11 @@ type Service interface {
	// Get a change.
	Get(ctx context.Context, repo string, id uint64) (Change, error)
	// ListCommits lists change commits.
	ListCommits(ctx context.Context, repo string, id uint64) ([]Commit, error)
	// Get a change diff.
	GetDiff(ctx context.Context, repo string, id uint64, opt *ListCommitsOptions) ([]byte, error)
	GetDiff(ctx context.Context, repo string, id uint64, opt *GetDiffOptions) ([]byte, error)

	// ListComments lists comments for specified change id.
	ListComments(ctx context.Context, repo string, id uint64, opt *ListCommentsOptions) ([]issues.Comment, error)
	// ListEvents lists events for specified change id.
	ListEvents(ctx context.Context, repo string, id uint64, opt *ListCommentsOptions) ([]issues.Event, error)
@@ -72,11 +72,11 @@ type StateFilter State
const (
	// AllStates is a state filter that includes all issues.
	AllStates StateFilter = "all"
)

type ListCommitsOptions struct {
type GetDiffOptions struct {
	// Commit is the commit ID of the commit to fetch.
	Commit string
}

// ListCommentsOptions controls pagination.
gerritapi/gerritapi.go
@@ -148,11 +148,11 @@ func (s service) ListCommits(ctx context.Context, _ string, id uint64) ([]change
		}
	}
	return commits, nil
}

func (s service) GetDiff(ctx context.Context, _ string, id uint64, opt *changes.ListCommitsOptions) ([]byte, error) {
func (s service) GetDiff(ctx context.Context, _ string, id uint64, opt *changes.GetDiffOptions) ([]byte, error) {
	switch opt {
	case nil:
		diff, _, err := s.cl.Changes.GetPatch(fmt.Sprint(id), "current", &gerrit.PatchOptions{
			Path: "src", // TODO.
		})
githubapi/githubapi.go
@@ -229,11 +229,11 @@ func (s service) ListCommits(ctx context.Context, rs string, id uint64) ([]chang
		})
	}
	return commits, nil
}

func (s service) GetDiff(ctx context.Context, rs string, id uint64, opt *changes.ListCommitsOptions) ([]byte, error) {
func (s service) GetDiff(ctx context.Context, rs string, id uint64, opt *changes.GetDiffOptions) ([]byte, error) {
	repo, err := ghRepoSpec(rs)
	if err != nil {
		// TODO: Map to 400 Bad Request HTTP error.
		return nil, err
	}
maintner/maintner.go
@@ -108,11 +108,11 @@ func (s service) Get(ctx context.Context, _ string, id uint64) (changes.Change,

func (s service) ListCommits(ctx context.Context, _ string, id uint64) ([]changes.Commit, error) {
	return nil, fmt.Errorf("ListCommits: not implemented")
}

func (s service) GetDiff(ctx context.Context, _ string, id uint64, opt *changes.ListCommitsOptions) ([]byte, error) {
func (s service) GetDiff(ctx context.Context, _ string, id uint64, opt *changes.GetDiffOptions) ([]byte, error) {
	// TODO.
	return nil, fmt.Errorf("GetDiff: not implemented")
}

func state(status string) changes.State {