change

package
v0.0.0-...-c858694 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package change provides a change service definition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	ID        uint64
	State     state.Change
	Title     string
	Labels    []issues.Label
	Author    users.User
	CreatedAt time.Time
	Replies   int // Number of replies to this change (not counting the mandatory change description comment).

	Commits      int // Number of commits (not populated during list operation).
	ChangedFiles int // Number of changed files (not populated during list operation).
}

Change represents a change in a repository.

type ClosedEvent

type ClosedEvent struct {
	Closer        interface{} // Change (with State, Title), Commit (with SHA, Message, Author.AvatarURL), nil.
	CloserHTMLURL string      // If Closer is not nil.
}

ClosedEvent is when a change is closed.

type Comment

type Comment struct {
	ID        string
	User      users.User
	CreatedAt time.Time
	Edited    *Edited // Edited is nil if the comment hasn't been edited.
	Body      string
	Reactions []reactions.Reaction
	Editable  bool // Editable represents whether the current user (if any) can perform edit operations on this comment.
}

Comment represents a comment left on a change. TODO: Consider removing in favor of Review with commented state and no inline comments.

type CommentRequest

type CommentRequest struct {
	ID       string
	Reaction *reactions.EmojiID // If not nil, toggle this reaction.
}

CommentRequest is a request to edit a comment.

type Commit

type Commit struct {
	SHA        string
	Message    string // TODO: Consider splitting into Subject, Body.
	Author     users.User
	AuthorTime time.Time
}

type CommitEvent

type CommitEvent struct {
	SHA     string
	Subject string
}

CommitEvent is when a change gets a new commit.

type DeletedEvent

type DeletedEvent struct {
	Type string // "branch", "comment".
	Name string
}

DeletedEvent is a delete event. THINK: Merge with "github.com/shurcooL/events/event".Delete?

type Edited

type Edited struct {
	By users.User
	At time.Time
}

Edited provides the actor and timing information for an edited item.

type GetDiffOptions

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

type InlineComment

type InlineComment struct {
	ID        string
	File      string
	Line      int
	Body      string
	Reactions []reactions.Reaction
}

InlineComment represents an inline comment that was left as part of a review.

type LabeledEvent

type LabeledEvent struct {
	Label issues.Label
}

LabeledEvent is when a change is labeled.

type ListOptions

type ListOptions struct {
	Filter StateFilter
}

ListOptions are options for list and count operations.

type ListTimelineOptions

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
}

ListTimelineOptions controls pagination.

type MergedEvent

type MergedEvent struct {
	CommitID      string
	CommitHTMLURL string // Optional.
	RefName       string
}

type RenamedEvent

type RenamedEvent struct {
	From string
	To   string
}

RenamedEvent is when a change is renamed.

type ReopenedEvent

type ReopenedEvent struct{}

ReopenedEvent is when a change is reopened.

type Review

type Review struct {
	ID        string
	User      users.User
	CreatedAt time.Time
	Edited    *Edited // Edited is nil if the review hasn't been edited.
	State     state.Review
	Body      string // Optional.
	Reactions []reactions.Reaction
	Editable  bool // Editable represents whether the current user (if any) can perform edit operations on this review.
	Comments  []InlineComment
}

Review represents a review left on a change.

type ReviewRequestRemovedEvent

type ReviewRequestRemovedEvent struct {
	RequestedReviewer users.User
}

type ReviewRequestedEvent

type ReviewRequestedEvent struct {
	RequestedReviewer users.User
}

type Service

type Service interface {
	// List changes.
	List(ctx context.Context, repo string, opt ListOptions) ([]Change, error)
	// 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 (change.Comment, change.Review, change.TimelineItem) for specified change id.
	ListTimeline(ctx context.Context, repo string, id uint64, opt *ListTimelineOptions) ([]interface{}, error)
	// ListCommits lists change commits, from first to last.
	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)

	// EditComment edits a comment.
	EditComment(ctx context.Context, repo string, id uint64, cr CommentRequest) (Comment, error)

	// ThreadType reports the notification thread type for this service in repo.
	ThreadType(ctx context.Context, repo string) (string, error)
}

Service defines methods of a change tracking service.

type StateFilter

type StateFilter string

StateFilter is a filter by state.

const (
	// FilterOpen is a state filter that includes open changes.
	FilterOpen StateFilter = "open"
	// FilterClosedMerged is a state filter that includes closed and merged changes.
	FilterClosedMerged StateFilter = "closed|merged"
	// FilterAll is a state filter that includes all changes.
	FilterAll StateFilter = "all"
)

type TimelineItem

type TimelineItem struct {
	ID        string // TODO: See if this belongs here.
	Actor     users.User
	CreatedAt time.Time

	// Payload specifies the event type. It's one of:
	// ClosedEvent, ReopenedEvent, ..., MergedEvent, DeletedEvent.
	Payload interface{}
}

TimelineItem represents a timeline item.

type UnlabeledEvent

type UnlabeledEvent struct {
	Label issues.Label
}

UnlabeledEvent is when a change is unlabeled.

Directories

Path Synopsis
Package fs will implement change.Service using a virtual filesystem, once change.Service API is finalized.
Package fs will implement change.Service using a virtual filesystem, once change.Service API is finalized.
Package gerritapi implements a read-only change.Service using Gerrit API client.
Package gerritapi implements a read-only change.Service using Gerrit API client.
Package githubapi implements a change.Service using GitHub API clients.
Package githubapi implements a change.Service using GitHub API clients.
Package httpclient contains change.Service implementation over HTTP.
Package httpclient contains change.Service implementation over HTTP.
Package httphandler contains an API handler for change.Service.
Package httphandler contains an API handler for change.Service.
Package httproute contains route paths for httpclient, httphandler.
Package httproute contains route paths for httpclient, httphandler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL