Documentation
¶
Overview ¶
Package github defines provider-neutral GitHub identities, models, enums, normalization rules, and URL parsing shared across the app. Keep `gh` CLI behavior, REST or GraphQL transport, and command formatting out.
Index ¶
- Constants
- Variables
- func BuildRunJobIDFromURL(raw string) (int, bool)
- func BuildRunPathFromURL(raw string) string
- func CanonicalPullRequestURL(repository string, number int) string
- func NormalizeNotificationSubjectTarget(repository string, id int) (string, error)
- func NormalizePullRequestDiffFileTeamOwners(teamOwners []string) []string
- func NormalizePullRequestDiffText(text string) string
- func NormalizePullRequestIdentity(repository string, number int) (string, int, error)
- func PullRequestCommitChangesURL(repository Repository, number int, commitOID string) (string, bool)
- func PullRequestHTMLURL(repository string, number int) string
- func RepositoryShortName(repository RepositoryRef) string
- type BuildInfo
- type BuildRunJob
- type BuildRunReference
- type CommitDiff
- type ConnectedUser
- type IssueDetail
- type Notification
- type NotificationBulkReadResult
- type NotificationSubject
- type PullRequest
- type PullRequestAuthor
- type PullRequestAutoMergeRequest
- type PullRequestBuildRunJob
- type PullRequestComment
- type PullRequestCommentAuthor
- type PullRequestCommit
- type PullRequestCommitAuthor
- type PullRequestDetail
- type PullRequestDiff
- type PullRequestDiffFile
- type PullRequestInlineComment
- type PullRequestLabel
- type PullRequestMergeQueueEntry
- type PullRequestRequestedReviewer
- type PullRequestReview
- type PullRequestReviewEvent
- type PullRequestReviewRequest
- type PullRequestReviewRequestOrganization
- type PullRequestReviewThread
- type PullRequestReviewThreadTarget
- type PullRequestStatusCheck
- type PullRequestSummary
- type ReactionContent
- type ReactionGroup
- type ReleaseDetail
- type Repository
- type RepositoryRef
- type ReviewEvent
- type ReviewThread
- type ReviewThreadTarget
Constants ¶
View Source
const ( NotificationSubjectTypePullRequest = "PullRequest" NotificationSubjectTypeIssue = "Issue" NotificationSubjectTypeRelease = "Release" )
View Source
const ( ReviewEventComment ReviewEvent = "COMMENT" ReviewEventApprove ReviewEvent = "APPROVE" ReviewEventRequestChanges ReviewEvent = "REQUEST_CHANGES" PullRequestReviewEventComment PullRequestReviewEvent = ReviewEventComment PullRequestReviewEventApprove PullRequestReviewEvent = ReviewEventApprove PullRequestReviewEventRequestChanges PullRequestReviewEvent = ReviewEventRequestChanges )
Variables ¶
View Source
var ( ErrMissingPullRequestBuildLink = errors.New("missing pull request build link") ErrInvalidPullRequestBuildLink = errors.New("invalid pull request build link") ErrPullRequestBuildRunJobNotFound = errors.New("pull request build run job not found") )
View Source
var ( ErrUnauthenticated = errors.New("gh is not authenticated") ErrEmptyConnectedUser = errors.New("empty connected user response") )
View Source
var ( ErrInvalidPullRequestURL = errors.New("invalid GitHub pull request URL") ErrMissingPullRequestIdentity = errors.New("missing pull request identity") )
View Source
var ( ErrInvalidReviewEvent = errors.New("invalid pull request review submission") ErrInvalidReviewThreadTarget = errors.New("invalid pull request review thread target") )
View Source
var ErrMissingNotificationSubjectTarget = errors.New("missing notification subject target")
View Source
var SupportedReactionContents = []ReactionContent{ ReactionContentThumbsUp, ReactionContentThumbsDown, ReactionContentLaugh, ReactionContentHooray, ReactionContentConfused, ReactionContentHeart, ReactionContentRocket, ReactionContentEyes, }
Functions ¶
func BuildRunJobIDFromURL ¶
func BuildRunPathFromURL ¶
func CanonicalPullRequestURL ¶
func NormalizePullRequestDiffFileTeamOwners ¶ added in v0.6.1
func NormalizePullRequestDiffText ¶ added in v0.6.1
func PullRequestCommitChangesURL ¶ added in v0.7.0
func PullRequestCommitChangesURL(repository Repository, number int, commitOID string) (string, bool)
func PullRequestHTMLURL ¶
func RepositoryShortName ¶ added in v0.7.0
func RepositoryShortName(repository RepositoryRef) string
Types ¶
type BuildRunJob ¶
type BuildRunReference ¶
func ParseBuildRunReferenceFromURL ¶
func ParseBuildRunReferenceFromURL(raw string) (BuildRunReference, error)
type CommitDiff ¶ added in v0.7.0
type CommitDiff struct {
Files []PullRequestDiffFile `json:"files"`
}
type ConnectedUser ¶
type IssueDetail ¶
type IssueDetail struct {
Title string `json:"title"`
Number int `json:"number"`
URL string `json:"html_url"`
Body string `json:"body"`
BodyHTML string `json:"bodyHTML,omitempty"`
Author *PullRequestAuthor `json:"user"`
State string `json:"state"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Labels []PullRequestLabel `json:"labels"`
Assignees []PullRequestAuthor `json:"assignees"`
Comments int `json:"comments"`
}
type Notification ¶
type Notification struct {
ID string `json:"id"`
Done bool `json:"done"`
Unread bool `json:"unread"`
Reason string `json:"reason"`
UpdatedAt string `json:"updated_at"`
LastReadAt string `json:"last_read_at"`
URL string `json:"url"`
SubscriptionURL string `json:"subscription_url"`
Repository RepositoryRef `json:"repository"`
Subject NotificationSubject `json:"subject"`
}
func (Notification) IssueIdentity ¶
func (notification Notification) IssueIdentity() (string, int, bool)
func (Notification) PullRequestSummary ¶
func (notification Notification) PullRequestSummary() (PullRequestSummary, bool)
func (Notification) ReleaseIdentity ¶
func (notification Notification) ReleaseIdentity() (string, int, bool)
type NotificationBulkReadResult ¶
type NotificationBulkReadResult struct {
Accepted bool
}
type NotificationSubject ¶
type PullRequest ¶
type PullRequest = PullRequestSummary
type PullRequestAuthor ¶
type PullRequestAutoMergeRequest ¶ added in v0.6.0
type PullRequestAutoMergeRequest struct {
EnabledAt string `json:"enabledAt"`
}
type PullRequestBuildRunJob ¶
type PullRequestBuildRunJob = BuildRunJob
type PullRequestComment ¶
type PullRequestComment struct {
ID string `json:"id"`
Author *PullRequestCommentAuthor `json:"author"`
Body string `json:"body"`
BodyHTML string `json:"bodyHTML,omitempty"`
CreatedAt string `json:"createdAt"`
URL string `json:"url"`
DiffHunk string `json:"diffHunk"`
State string `json:"state"`
ViewerDidAuthor bool `json:"viewerDidAuthor"`
ReactionGroups []ReactionGroup `json:"reactionGroups,omitempty"`
}
type PullRequestCommentAuthor ¶
type PullRequestCommentAuthor struct {
Login string `json:"login"`
}
type PullRequestCommit ¶
type PullRequestCommit struct {
OID string `json:"oid"`
MessageHeadline string `json:"messageHeadline"`
MessageBody string `json:"messageBody"`
MessageBodyHTML string `json:"messageBodyHTML,omitempty"`
AuthoredDate string `json:"authoredDate"`
CommittedDate string `json:"committedDate"`
Authors []PullRequestCommitAuthor `json:"authors"`
}
type PullRequestCommitAuthor ¶
type PullRequestDetail ¶
type PullRequestDetail struct {
ID string `json:"id,omitempty"`
Title string `json:"title"`
Number int `json:"number"`
URL string `json:"url"`
Body string `json:"body"`
BodyHTML string `json:"bodyHTML,omitempty"`
Author *PullRequestAuthor `json:"author"`
State string `json:"state"`
IsDraft bool `json:"isDraft"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Labels []PullRequestLabel `json:"labels"`
Assignees []PullRequestAuthor `json:"assignees"`
ReviewDecision string `json:"reviewDecision"`
ReviewRequests []PullRequestReviewRequest `json:"reviewRequests"`
BaseRefName string `json:"baseRefName"`
HeadRefName string `json:"headRefName"`
MergeStateStatus string `json:"mergeStateStatus"`
Mergeable string `json:"mergeable"`
AutoMergeRequest *PullRequestAutoMergeRequest `json:"autoMergeRequest,omitempty"`
IsMergeQueueEnabled bool `json:"isMergeQueueEnabled,omitempty"`
IsInMergeQueue bool `json:"isInMergeQueue,omitempty"`
MergeQueueEntry *PullRequestMergeQueueEntry `json:"mergeQueueEntry,omitempty"`
ViewerCanEnableAutoMerge bool `json:"viewerCanEnableAutoMerge,omitempty"`
OutOfDateWithBase bool `json:"outOfDateWithBase,omitempty"`
ReactionGroups []ReactionGroup `json:"reactionGroups,omitempty"`
Comments []PullRequestComment `json:"comments"`
Commits []PullRequestCommit `json:"commits"`
Reviews []PullRequestReview `json:"reviews"`
InlineComments []PullRequestInlineComment `json:"-"`
InlineCommentThreads []ReviewThread `json:"-"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
ChangedFiles int `json:"changedFiles"`
StatusCheckRollup []BuildInfo `json:"statusCheckRollup"`
}
type PullRequestDiff ¶
type PullRequestDiff struct {
UnifiedDiff string
Files []PullRequestDiffFile
Threads []ReviewThread
FileTeamOwnersAttempted bool `json:"fileTeamOwnersAttempted,omitempty"`
}
type PullRequestDiffFile ¶
type PullRequestInlineComment ¶
type PullRequestInlineComment struct {
ID string `json:"node_id"`
Author *PullRequestCommentAuthor `json:"user"`
Body string `json:"body"`
BodyHTML string `json:"bodyHTML,omitempty"`
CreatedAt string `json:"created_at"`
URL string `json:"html_url"`
Path string `json:"path"`
DiffHunk string `json:"diff_hunk"`
Line int `json:"line"`
OriginalLine int `json:"original_line"`
StartLine int `json:"start_line"`
OriginalStartLine int `json:"original_start_line"`
Side string `json:"side"`
StartSide string `json:"start_side"`
SubjectType string `json:"subject_type"`
ReactionGroups []ReactionGroup `json:"reactionGroups,omitempty"`
}
type PullRequestLabel ¶
type PullRequestLabel struct {
Name string `json:"name"`
}
type PullRequestMergeQueueEntry ¶ added in v0.7.0
type PullRequestRequestedReviewer ¶
type PullRequestRequestedReviewer struct {
TypeName string `json:"__typename"`
Login string `json:"login"`
Name string `json:"name"`
Slug string `json:"slug"`
Organization *PullRequestReviewRequestOrganization `json:"organization"`
}
type PullRequestReview ¶
type PullRequestReview struct {
ID string `json:"id"`
Author *PullRequestCommentAuthor `json:"author"`
Body string `json:"body"`
State string `json:"state"`
SubmittedAt string `json:"submittedAt"`
ReactionGroups []ReactionGroup `json:"reactionGroups,omitempty"`
}
type PullRequestReviewEvent ¶
type PullRequestReviewEvent = ReviewEvent
type PullRequestReviewRequest ¶
type PullRequestReviewRequest struct {
RequestedReviewer PullRequestRequestedReviewer `json:"requestedReviewer"`
}
func (*PullRequestReviewRequest) UnmarshalJSON ¶
func (reviewRequest *PullRequestReviewRequest) UnmarshalJSON(data []byte) error
type PullRequestReviewRequestOrganization ¶
type PullRequestReviewRequestOrganization struct {
Login string `json:"login"`
}
type PullRequestReviewThread ¶
type PullRequestReviewThread = ReviewThread
type PullRequestReviewThreadTarget ¶
type PullRequestReviewThreadTarget = ReviewThreadTarget
type PullRequestStatusCheck ¶
type PullRequestStatusCheck = BuildInfo
type PullRequestSummary ¶
type PullRequestSummary struct {
ID string `json:"id"`
Title string `json:"title"`
Number int `json:"number"`
Repository RepositoryRef `json:"repository"`
URL string `json:"url"`
Body string `json:"body"`
State string `json:"state"`
IsDraft bool `json:"isDraft"`
UpdatedAt string `json:"updatedAt"`
ReviewDecision string `json:"reviewDecision"`
ReviewRequests []PullRequestReviewRequest `json:"reviewRequests"`
MergeStateStatus string `json:"mergeStateStatus"`
Mergeable string `json:"mergeable"`
AutoMergeRequest *PullRequestAutoMergeRequest `json:"autoMergeRequest,omitempty"`
IsMergeQueueEnabled bool `json:"isMergeQueueEnabled,omitempty"`
IsInMergeQueue bool `json:"isInMergeQueue,omitempty"`
MergeQueueEntry *PullRequestMergeQueueEntry `json:"mergeQueueEntry,omitempty"`
ViewerCanEnableAutoMerge bool `json:"viewerCanEnableAutoMerge,omitempty"`
StatusCheckRollupState string `json:"statusCheckRollupState"`
}
func ParsePullRequestURL ¶
func ParsePullRequestURL(raw string) (PullRequestSummary, error)
type ReactionContent ¶
type ReactionContent string
const ( ReactionContentThumbsUp ReactionContent = "+1" ReactionContentThumbsDown ReactionContent = "-1" ReactionContentLaugh ReactionContent = "laugh" ReactionContentHooray ReactionContent = "hooray" ReactionContentConfused ReactionContent = "confused" ReactionContentHeart ReactionContent = "heart" ReactionContentRocket ReactionContent = "rocket" ReactionContentEyes ReactionContent = "eyes" )
func NormalizeReactionContent ¶
func NormalizeReactionContent(value string) ReactionContent
type ReactionGroup ¶
type ReactionGroup struct {
Content ReactionContent `json:"content"`
TotalCount int `json:"totalCount"`
ViewerHasReacted bool `json:"viewerHasReacted"`
}
func (*ReactionGroup) UnmarshalJSON ¶
func (group *ReactionGroup) UnmarshalJSON(data []byte) error
type ReleaseDetail ¶
type ReleaseDetail struct {
Name string `json:"name"`
TagName string `json:"tag_name"`
URL string `json:"html_url"`
Body string `json:"body"`
BodyHTML string `json:"bodyHTML,omitempty"`
Draft bool `json:"draft"`
PreRelease bool `json:"prerelease"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
PublishedAt string `json:"published_at"`
Author *PullRequestAuthor `json:"author"`
}
type Repository ¶
type Repository = RepositoryRef
type RepositoryRef ¶
func (*RepositoryRef) UnmarshalJSON ¶
func (repository *RepositoryRef) UnmarshalJSON(data []byte) error
type ReviewEvent ¶
type ReviewEvent string
func NormalizeReviewEvent ¶
func NormalizeReviewEvent(event ReviewEvent) (ReviewEvent, error)
type ReviewThread ¶
type ReviewThread struct {
ID string `json:"id"`
IsResolved bool `json:"isResolved"`
IsOutdated bool `json:"isOutdated"`
ViewerCanResolve bool `json:"viewerCanResolve"`
ViewerCanUnresolve bool `json:"viewerCanUnresolve"`
Path string `json:"path"`
Line int `json:"line"`
OriginalLine int `json:"originalLine"`
StartLine int `json:"startLine"`
OriginalStartLine int `json:"originalStartLine"`
DiffSide string `json:"diffSide"`
StartDiffSide string `json:"startDiffSide"`
Comments []PullRequestComment `json:"-"`
}
type ReviewThreadTarget ¶
type ReviewThreadTarget struct {
Path string
Line int
Side string
StartLine int
StartSide string
SubjectType string
}
func NormalizeReviewThreadTarget ¶
func NormalizeReviewThreadTarget(target ReviewThreadTarget) (ReviewThreadTarget, error)
Click to show internal directories.
Click to hide internal directories.