issues: github.com/shurcooL/issues Index | Files | Directories

package issues

import "github.com/shurcooL/issues"

Package issues provides an issues service definition.

Index

Package Files

events.go issues.go options.go

type Comment Uses

type Comment struct {
    ID        uint64
    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 (or the encompassing issue).
}

Comment represents a comment left on an issue.

func (Comment) Validate Uses

func (c Comment) Validate() error

Validate returns non-nil error if the comment is invalid.

type CommentRequest Uses

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

CommentRequest is a request to edit a comment.

func (CommentRequest) Validate Uses

func (cr CommentRequest) Validate() (requiresEdit bool, err error)

Validate validates the comment edit request, returning an non-nil error if it's invalid. requiresEdit reports if the edit request needs edit rights or if it can be done by anyone that can react.

type CopierFrom Uses

type CopierFrom interface {
    // CopyFrom copies all issues from src for specified repo.
    // ctx should provide permission to access all issues in src.
    CopyFrom(ctx context.Context, src Service, repo RepoSpec) error
}

CopierFrom is an optional interface that allows copying issues between services.

type Edited Uses

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

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

type Event Uses

type Event struct {
    ID        uint64
    Actor     users.User
    CreatedAt time.Time
    Type      EventType
    Rename    *Rename // Rename is only provided for Renamed events.
    Label     *Label  // Label is only provided for Labeled and Unlabeled events.
}

Event represents an event that occurred around an issue.

type EventType Uses

type EventType string

EventType is the type of an event.

const (
    // Reopened is when an issue is reopened.
    Reopened EventType = "reopened"
    // Closed is when an issue is closed.
    Closed EventType = "closed"
    // Renamed is when an issue is renamed.
    Renamed EventType = "renamed"
    // Labeled is when an issue is labeled.
    Labeled EventType = "labeled"
    // Unlabeled is when an issue is unlabeled.
    Unlabeled EventType = "unlabeled"
)

func (EventType) Valid Uses

func (et EventType) Valid() bool

Valid returns non-nil error if the event type is invalid.

type Issue Uses

type Issue struct {
    ID     uint64
    State  State
    Title  string
    Labels []Label
    Comment
    Replies int // Number of replies to this issue (not counting the mandatory issue description comment).
}

Issue represents an issue on a repository.

func (Issue) Validate Uses

func (i Issue) Validate() error

Validate returns non-nil error if the issue is invalid.

type IssueListOptions Uses

type IssueListOptions struct {
    State StateFilter
}

IssueListOptions are options for list operations.

type IssueRequest Uses

type IssueRequest struct {
    State *State
    Title *string
}

IssueRequest is a request to edit an issue. To edit the body, use EditComment with comment ID 0.

func (IssueRequest) Validate Uses

func (ir IssueRequest) Validate() error

Validate returns non-nil error if the issue request is invalid.

type Label Uses

type Label struct {
    Name  string
    Color RGB
}

Label represents a label.

func (Label) FontColor Uses

func (l Label) FontColor() string

FontColor returns one of "#fff" or "#000", whichever is a better fit for the font color given the label color.

type ListOptions Uses

type ListOptions struct {
    // Start is the index of first result to retrieve, zero-indexed.
    Start int

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

ListOptions controls pagination.

type RGB Uses

type RGB struct {
    R, G, B uint8
}

TODO: Dedup.

RGB represents a 24-bit color without alpha channel.

func (RGB) HexString Uses

func (c RGB) HexString() string

HexString returns a hexadecimal color string. For example, "#ff0000" for red.

func (RGB) RGBA Uses

func (c RGB) RGBA() (r, g, b, a uint32)

type Rename Uses

type Rename struct {
    From string
    To   string
}

Rename provides details for a Renamed event.

type RepoSpec Uses

type RepoSpec struct {
    URI string // URI is clean '/'-separated URI. E.g., "user/repo".
}

RepoSpec is a specification for a repository.

func (RepoSpec) String Uses

func (rs RepoSpec) String() string

String implements fmt.Stringer.

type Service Uses

type Service interface {
    // List issues.
    List(ctx context.Context, repo RepoSpec, opt IssueListOptions) ([]Issue, error)
    // Count issues.
    Count(ctx context.Context, repo RepoSpec, opt IssueListOptions) (uint64, error)

    // Get an issue.
    Get(ctx context.Context, repo RepoSpec, id uint64) (Issue, error)

    // ListComments lists comments for specified issue id.
    ListComments(ctx context.Context, repo RepoSpec, id uint64, opt *ListOptions) ([]Comment, error)
    // ListEvents lists events for specified issue id.
    ListEvents(ctx context.Context, repo RepoSpec, id uint64, opt *ListOptions) ([]Event, error)

    // Create a new issue.
    Create(ctx context.Context, repo RepoSpec, issue Issue) (Issue, error)
    // CreateComment creates a new comment for specified issue id.
    CreateComment(ctx context.Context, repo RepoSpec, id uint64, comment Comment) (Comment, error)

    // Edit the specified issue id.
    Edit(ctx context.Context, repo RepoSpec, id uint64, ir IssueRequest) (Issue, []Event, error)
    // EditComment edits comment of specified issue id.
    EditComment(ctx context.Context, repo RepoSpec, id uint64, cr CommentRequest) (Comment, error)
}

Service defines methods of an issue tracking service.

type State Uses

type State string

State represents the issue state.

const (
    // OpenState is when an issue is open.
    OpenState State = "open"
    // ClosedState is when an issue is closed.
    ClosedState State = "closed"
)

type StateFilter Uses

type StateFilter State

StateFilter is a filter by state.

const (
    // AllStates is a state filter that includes all issues.
    AllStates StateFilter = "all"
)

Directories

PathSynopsis
asanaapiPackage asanaapi implements issues.Service using Asana API client.
fsPackage fs implements issues.Service using a filesystem.
githubapiPackage githubapi implements issues.Service using GitHub API client.

Package issues imports 7 packages (graph) and is imported by 11 packages. Updated 2017-02-25. Refresh now. Tools for package owners.