dmitri.shuralyov.com/service/change

Merge ListComments, ListEvents into ListTimeline.

There's no longer a clean distinction between comments and events.
There are other timeline item types that don't fit into either category
cleanly. Also, underlying implementations for various APIs are very
similar and have overlap. As a result, it makes sense to merge these
two methods into one.
dmitshur committed 7 years ago commit 10c5b0f59dc1ffb8cf59c4a22110e89f803affa5
Showing partial commit. Full Commit
Collapse all
changes.go
@@ -16,19 +16,17 @@ type Service interface {
	// Count changes.
	Count(ctx context.Context, repo string, opt ListOptions) (uint64, error)

	// Get a change.
	Get(ctx context.Context, repo string, id uint64) (Change, error)

	// ListTimeline lists timeline items (issues.Comment, issues.Event) for specified change id.
	ListTimeline(ctx context.Context, repo string, id uint64, opt *ListTimelineOptions) ([]interface{}, 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 *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)
}

// Change represents a change in a repository.
type Change struct {
	ID        uint64
@@ -59,11 +57,11 @@ const (
	ClosedState State = "closed"
	// MergedState is when a change is merged.
	MergedState State = "merged"
)

// ListOptions are options for list operations.
// ListOptions are options for list and count operations.
type ListOptions struct {
	Filter StateFilter
}

// StateFilter is a filter by state.
@@ -76,18 +74,18 @@ const (
	FilterClosedMerged StateFilter = "closed|merged"
	// FilterAll is a state filter that includes all changes.
	FilterAll StateFilter = "all"
)

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

// ListCommentsOptions controls pagination.
type ListCommentsOptions struct {
// ListTimelineOptions controls pagination.
type ListTimelineOptions struct {
	// Start is the index of first result to retrieve, zero-indexed.
	Start int

	// Length is the number of results to include.
	Length int
}

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