pr

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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 pr is the GitHub plugin's pull request: its reference and the row the plugin's store keeps of it.

Index

Constants

View Source
const (
	KindOpened               = "opened"
	KindPush                 = "push" // Key = commit oid
	KindReviewRequest        = "review_requested"
	KindReviewRequestRemoved = "review_request_removed"
	KindReview               = "review"  // Key = review id, Data = STATE:headOid
	KindComment              = "comment" // Key = comment id
	KindCheck                = "check"   // Key = headOid:STATE, At = first sighting
	KindReady                = "ready"
	KindDraft                = "draft"  // back to draft; Actor = who converted it
	KindMerged               = "merged" // Actor = the merger, Data = the merge commit oid
	KindClosed               = "closed"
	KindRoundSent            = "round_sent"
	KindRoundHeld            = "round_held"
	KindRoundBlocked         = "round_blocked"
	KindRoundUnblocked       = "round_unblocked" // Data = what cleared it
	KindWouldAddress         = "would_address"
	KindNudged               = "nudged" // Data = who was asked
	KindTracked              = "tracked"
	KindUntracked            = "untracked"
	KindStatus               = "status"     // Data = board column
	KindFollowed             = "followed"   // Key = the time, Data = the reasons, ","-joined
	KindUnfollowed           = "unfollowed" // Key = the time, Data = the reasons it was followed for
	KindReviewEnded          = "review_ended"
)

The kinds of the events the plugin records; plugin.toml declares the timeline's.

View Source
const (
	ReviewApproved         = "APPROVED"
	ReviewChangesRequested = "CHANGES_REQUESTED"
	ReviewCommented        = "COMMENTED"
	ReviewDismissed        = "DISMISSED"
)

The states of a review.

View Source
const (
	StateOpen   = "OPEN"
	StateMerged = "MERGED"
	StateClosed = "CLOSED"
)

The states of a pull request.

View Source
const Provider = "github"

Provider is the provider id of the plugin's units.

View Source
const ReasonTracked = "tracked"

ReasonTracked is the scope reason of a pull request the user tracks.

View Source
const ReviewTurnsFollowed = 30 * 24 * time.Hour

ReviewTurnsFollowed bounds how long after its newest review round a pull request stays followed for its follow-ups.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Ref) int

Compare orders refs by owner, repo and number.

func OneLine

func OneLine(s string, max int) string

OneLine is s on one line: control and invisible characters dropped or blanked, whitespace collapsed, cut to max runes.

func RequestKey

func RequestKey(reviewer string, at time.Time) string

RequestKey is the key of a review request or of its removal: the reviewer and the request's time to the second, so a re-request is its own event.

Types

type Check

type Check struct {
	Name    string
	Pending bool
	Failed  bool
	URL     string
	Summary string
}

Check is one status check or check run on the head commit.

type Comment

type Comment struct {
	ID        string
	Author    string
	CreatedAt time.Time
}

type Commit

type Commit struct {
	Oid     string
	Parents int
}

type Event

type Event struct {
	PR    Ref
	Kind  string
	Key   string // natural key; "" for singletons
	Actor string
	At    time.Time
	Data  string
}

Event is an event on a pull request, which the host keeps.

type Facts

type Facts struct {
	Ref
	State             string
	IsDraft           bool
	Title             string
	HeadRefName       string
	BaseRefName       string
	HeadRefOid        string
	IsCrossRepository bool
	// Visibility is the repository's visibility, lower-case: public,
	// private or internal; empty when not read.
	Visibility        string
	Author            string
	AuthorAssociation string
	ReviewDecision    string
	// Mergeable is MERGEABLE, CONFLICTING or UNKNOWN (GitHub computes it
	// lazily); empty when not read.
	Mergeable string
	// ChecksState is the status check rollup of the head commit; empty when
	// the repository has no checks.
	ChecksState string
	// NewestChangesRequestOid is the commit the newest CHANGES_REQUESTED
	// review was left on.
	NewestChangesRequestOid string

	Reviews        []Review
	LatestReviews  []Review
	Comments       []Comment
	ReviewRequests []string
	// ViewerRequested says the viewer's review is requested by name.
	ViewerRequested bool
	Commits         []Commit
	// OpenThreads are the unresolved review threads; ThreadsTotal counts
	// every thread, read or not.
	OpenThreads  []Thread
	ThreadsTotal int
	Checks       []Check
	Labels       []string
}

Facts are a pull request as the decide rules read it.

type FailingCheck

type FailingCheck struct {
	Name    string `json:"name"`
	URL     string `json:"url,omitempty"`
	Summary string `json:"summary,omitempty"`
}

type Override

type Override struct {
	Ref     Ref
	Adopted bool // taken over into the loop
	Tracked bool // added by hand; the store keeps ReasonTracked among its reasons while set
}

Override is what the user set on a pull request that the plugin keeps.

type PR

type PR struct {
	Ref            Ref
	Title          string
	Author         string
	State          string // OPEN, MERGED, CLOSED
	IsDraft        bool
	HeadOid        string
	HeadBranch     string
	BaseBranch     string
	IsFork         bool
	ChecksState    string   // SUCCESS, FAILURE, PENDING, "" (no checks)
	ReviewDecision string   // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, "" (no required reviews)
	ReviewRequests []string // current pending reviewers: logins and "team:org/slug"
	URL            string
	CreatedAt      time.Time
	UpdatedAt      time.Time
	MergedAt       time.Time
	ClosedAt       time.Time
	BodyEditedAt   time.Time
	ChangedFiles   int
	LastSeenAt     time.Time // last time a search or a by-ref read returned it
	Reasons        []string  // ownership reasons, sorted; empty means it left scope
	Workspace      Workspace // zero when none
	FailingChecks  []FailingCheck
	Mergeable      string    // MERGEABLE, CONFLICTING, UNKNOWN, "" (not read)
	MergeableAt    time.Time // when it was first seen CONFLICTING; zero otherwise
}

PR is a pull request as the plugin's store keeps it.

func (PR) Followed

func (p PR) Followed() bool

Followed tells whether a scope reason or a linked workspace holds the pull request.

type PullRequest

type PullRequest struct {
	Facts
	HeadRepositoryOwner string
}

PullRequest is a pull request as a read returned it: the facts the decide rules read and the head repository's owner.

type Ref

type Ref struct {
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Number int    `json:"number"`
}

func ParseKey

func ParseKey(key string) (Ref, error)

ParseKey reads a unit key, owner/repo#number.

func ParseURL

func ParseURL(raw string) (Ref, error)

ParseURL reads a pull request's page address.

func RefOf

func RefOf(u sdk.Unit) (Ref, bool)

RefOf is the pull request u names; false for a unit of another provider or a key that names none.

func (Ref) String

func (r Ref) String() string

String is the ref's unit key, owner/repo#number.

func (Ref) URL

func (r Ref) URL() string

URL is the pull request's page on GitHub.

func (Ref) Unit

func (r Ref) Unit() sdk.Unit

Unit is the plugin's unit of the reference.

type Review

type Review struct {
	ID          string
	State       string
	Author      string
	SubmittedAt time.Time
	CommitOid   string
	// HasContent is set by the author queries only. GitHub requires a body or
	// comments on the states other than APPROVED; an approval counts only
	// with inline comments, as reading every body would weigh the query.
	HasContent bool
	// ByViewer is set by the queries that ask GitHub whether the viewer wrote the review.
	ByViewer bool
}

type Thread

type Thread struct {
	LastAuthor string
	LastAt     time.Time
}

Thread is an unresolved review thread, by its last comment.

type Workspace

type Workspace struct {
	// Manager owns the workspace; ID is its id there.
	Manager     string   `json:"manager,omitempty"`
	ID          string   `json:"id"`
	DisplayName string   `json:"display_name"`
	Status      string   `json:"status"`
	IsReview    bool     `json:"is_review"`
	AgentStates []string `json:"agent_states"`
	Comment     string   `json:"comment"`
	// IsMain is the repository's main checkout on the pull request's branch,
	// which the loop never removes.
	IsMain bool `json:"is_main"`
}

Workspace is the workspace a pull request is linked to.

Jump to

Keyboard shortcuts

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