change: dmitri.shuralyov.com/service/change Index | Files | Directories

package change

import "dmitri.shuralyov.com/service/change"

Package change provides a change service definition.

Index

Package Files

change.go timeline.go

type Change Uses

type Change struct {
    ID        uint64
    State     State
    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 Uses

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 Uses

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 Uses

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

CommentRequest is a request to edit a comment.

type Commit Uses

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

type DeletedEvent Uses

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 Uses

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

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

type GetDiffOptions Uses

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

type InlineComment Uses

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 Uses

type LabeledEvent struct {
    Label issues.Label
}

LabeledEvent is when a change is labeled.

type ListOptions Uses

type ListOptions struct {
    Filter StateFilter
}

ListOptions are options for list and count operations.

type ListTimelineOptions Uses

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 Uses

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

type RenamedEvent Uses

type RenamedEvent struct {
    From string
    To   string
}

RenamedEvent is when a change is renamed.

type ReopenedEvent Uses

type ReopenedEvent struct{}

ReopenedEvent is when a change is reopened.

type Review Uses

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 Uses

type ReviewRequestRemovedEvent struct {
    RequestedReviewer users.User
}

type ReviewRequestedEvent Uses

type ReviewRequestedEvent struct {
    RequestedReviewer users.User
}

type Service Uses

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)
}

Service defines methods of a change tracking service.

type State Uses

type State string

State represents the change state.

const (
    // OpenState is when a change is open.
    OpenState State = "open"
    // ClosedState is when a change is closed.
    ClosedState State = "closed"
    // MergedState is when a change is merged.
    MergedState State = "merged"
)

type StateFilter Uses

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 Uses

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 Uses

type UnlabeledEvent struct {
    Label issues.Label
}

UnlabeledEvent is when a change is unlabeled.

Directories

PathSynopsis
fsPackage fs will implement change.Service using a virtual filesystem, once change.Service API is finalized.
gerritapiPackage gerritapi implements a read-only change.Service using Gerrit API client.
githubapiPackage githubapi implements a change.Service using GitHub API clients.
httpclientPackage httpclient contains change.Service implementation over HTTP.
httphandlerPackage httphandler contains an API handler for change.Service.
httproutePackage httproute contains route paths for httpclient, httphandler.
maintnerPackage maintner implements a read-only change.Service using a x/build/maintner corpus.

Package change imports 6 packages (graph) and is imported by 12 packages. Updated 2019-04-18. Refresh now. Tools for package owners.