timeline

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package timeline is the conversation the issue sheet and the review sheet show: the comments, reviews, and events of an issue or a pull request, one page of entries at a time, oldest first. Entries converts what the GitHub client read into the entries the window shows, and Cut shortens their texts so a sheet's cache stays within its size.

The two sheets share it and import nothing of each other. It is a leaf: it imports the GitHub client's types, the item and clock words, and textutil, and no service or store. Each type's JSON is what the window reads and what the issue sheet's cache, written by builds before this package, already holds, so a name or a tag here never changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HunkTail

func HunkTail(hunk string) []string

HunkTail is the last few lines of a diff hunk (hunkLines), the hunk's header left out and each line cut to hunkLineBytes, never nil: the lines a line comment is on, as the diff shows them.

Types

type Entry

type Entry struct {
	Kind       Kind   `json:"kind"`
	ID         string `json:"id"`
	At         string `json:"at"`
	Actor      string `json:"actor"`
	ActorIsBot bool   `json:"actorIsBot"`
	Mine       bool   `json:"mine"`

	// A comment's or a review's text, page, author's relationship to the repository, and
	// when it was edited; Trimmed says the cache cut the text short. Minimized says someone
	// folded it away, and MinimizedReason why, as an upper-case word. A merge's page is its
	// URL too.
	Body            string `json:"body"`
	Trimmed         bool   `json:"trimmed"`
	URL             string `json:"url"`
	Association     string `json:"association"`
	EditedAt        string `json:"editedAt"`
	Minimized       bool   `json:"minimized"`
	MinimizedReason string `json:"minimizedReason"`

	// Ref is the other item an event names; WillClose a mention that closes the issue once
	// merged; Commit a commit that closed it, or a merge's commit, as a short SHA;
	// DuplicateOf what a close as a duplicate names.
	Ref         *Ref        `json:"ref"`
	WillClose   bool        `json:"willClose"`
	Commit      string      `json:"commit"`
	DuplicateOf *Ref        `json:"duplicateOf"`
	StateReason StateReason `json:"stateReason"`

	Label    *Label `json:"label"`
	Assignee string `json:"assignee"`

	// From and To are a rename's titles, or a force push's commits, before and after it, as
	// short SHAs.
	From string `json:"from"`
	To   string `json:"to"`

	// ReviewState is a review's state, and Outdated says it was left on an earlier commit
	// than the head the sheet read. LineComments are its first line comments, and
	// MoreLineComments how many others it has, which GitHub shows.
	ReviewState      ReviewState   `json:"reviewState"`
	Outdated         bool          `json:"outdated"`
	LineComments     []LineComment `json:"lineComments"`
	MoreLineComments int           `json:"moreLineComments"`

	// Reviewer is whom a review was requested of: a user's login, or a team as "org/team",
	// "" for one the user can't see.
	Reviewer string `json:"reviewer"`

	// Branch is the branch a merge went into.
	Branch string `json:"branch"`
}

Entry is one comment, review, or event. Which fields are set depends on Kind.

func Cut

func Cut(body *string, trimmed *bool, entries []Entry, limit int) []Entry

Cut cuts the description, body, and every text of entries, each comment's and review's and each line comment's, longer than limit bytes, marking each one cut (trimmed for the description). It returns the entries cut, a copy, leaving the ones given as they were. Each text cut keeps its page, where the whole text is; no entry is dropped.

func Entries

func Entries(items []github.TimelineItem, viewer string) []Entry

Entries converts a page of a timeline, the viewer's own entries marked, skipping the types the sheets don't read. It never returns nil, nor an entry with a nil list.

func NonNil

func NonNil(entries []Entry) []Entry

NonNil returns entries, never nil, each with its lists never nil: what an older build's cache holds lacks the lists this build added.

type Kind

type Kind string

Kind is what one entry of a timeline is.

const (
	KindComment    Kind = "comment"
	KindMentioned  Kind = "mentioned"
	KindLinked     Kind = "linked"
	KindUnlinked   Kind = "unlinked"
	KindClosed     Kind = "closed"
	KindReopened   Kind = "reopened"
	KindAssigned   Kind = "assigned"
	KindUnassigned Kind = "unassigned"
	KindLabeled    Kind = "labeled"
	KindUnlabeled  Kind = "unlabeled"
	KindRenamed    Kind = "renamed"
	KindDuplicate  Kind = "duplicate"

	KindReviewed         Kind = "reviewed"
	KindMerged           Kind = "merged"
	KindForcePushed      Kind = "force_pushed"
	KindReviewRequested  Kind = "review_requested"
	KindReadyForReview   Kind = "ready_for_review"
	KindConvertedToDraft Kind = "converted_to_draft"
)

The timeline's kinds: both sheets' first, then those only a pull request has.

func KindOf

func KindOf(githubType string) (Kind, bool)

KindOf names a timeline item by its GitHub type; ok is false for one the sheets don't read.

type Label

type Label struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

Label is a label with its color as "#rrggbb", or "".

func LabelOf

func LabelOf(l *github.Label) *Label

LabelOf converts a label an event names, nil for none.

type LineComment

type LineComment struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	At        string   `json:"at"`
	Path      string   `json:"path"`
	Line      int      `json:"line"`
	StartLine int      `json:"startLine"`
	Outdated  bool     `json:"outdated"`
	Body      string   `json:"body"`
	Trimmed   bool     `json:"trimmed"`
	Hunk      []string `json:"hunk"`
}

LineComment is one of a review's comments on a line of the diff: the file and the lines it is on (StartLine 0 for one line), as the diff it was left on numbers them once it is Outdated, the lines having changed since; its text, which Trimmed says the cache cut short; and Hunk, the last lines of the diff up to the line, as the diff shows them.

type Page

type Page struct {
	Items  []Entry `json:"items"`
	Total  int     `json:"total"`
	Before string  `json:"before"`
}

Page is a page of a timeline, oldest first. Before is the cursor that reads the entries before it, "" when none come before it, and Total counts every entry of the whole timeline the sheet reads, so Total less the entries the sheet holds is how many it doesn't.

type Reaction

type Reaction struct {
	Content string `json:"content"`
	Count   int    `json:"count"`
}

Reaction counts one kind of reaction to the description, by GitHub's name for it.

func ReactionsOf

func ReactionsOf(rs []github.Reaction) []Reaction

ReactionsOf converts a description's reactions, never returning nil.

type Ref

type Ref struct {
	Kind        item.Kind   `json:"kind"`
	Repo        string      `json:"repo"`
	Number      int         `json:"number"`
	Title       string      `json:"title"`
	URL         string      `json:"url"`
	State       RefState    `json:"state"`
	StateReason StateReason `json:"stateReason"`
	Draft       bool        `json:"draft"`
}

Ref is a pull request or an issue the sheet names.

func RefOf

func RefOf(r *github.ItemRef) *Ref

RefOf converts a pull request or an issue GitHub named, nil for none.

func RefsOf

func RefsOf(refs []github.ItemRef) []Ref

RefsOf converts the pull requests and issues GitHub named, never returning nil.

type RefState

type RefState string

RefState is a pull request's or an issue's state.

const (
	StateOpen   RefState = "OPEN"
	StateClosed RefState = "CLOSED"
	StateMerged RefState = "MERGED"
)

The states.

type ReviewState

type ReviewState string

ReviewState is a review's state, as GitHub says it.

const (
	ReviewNone             ReviewState = ""
	ReviewApproved         ReviewState = "APPROVED"
	ReviewChangesRequested ReviewState = "CHANGES_REQUESTED"
	ReviewCommented        ReviewState = "COMMENTED"
	ReviewDismissed        ReviewState = "DISMISSED"
)

The review states the sheet shows; a review still pending is never shown.

type StateReason

type StateReason string

StateReason is why an issue is closed, or was reopened, as GitHub says it.

const (
	ReasonNone       StateReason = ""
	ReasonCompleted  StateReason = "COMPLETED"
	ReasonNotPlanned StateReason = "NOT_PLANNED"
	ReasonDuplicate  StateReason = "DUPLICATE"
	ReasonReopened   StateReason = "REOPENED"
)

The state reasons.

Jump to

Keyboard shortcuts

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