Documentation
¶
Overview ¶
Package githubcli will wrap `gh` CLI calls behind a testable adapter.
Index ¶
- Constants
- Variables
- func FormatAssignableUsersCommand(repository string) string
- func FormatPullRequestBuildRunCommand(repository string, check PullRequestStatusCheck) string
- func FormatPullRequestBuildRunJobLogCommand(repository string, jobDatabaseID int) string
- func FormatPullRequestBuildRunJobsCommand(repository string, check PullRequestStatusCheck) string
- func FormatPullRequestSearchCommand(commandArguments []string) string
- type Client
- func (client *Client) AddPullRequestReviewThread(pullRequestReviewID string, body string, target PullRequestReviewThreadTarget) error
- func (client *Client) AddPullRequestReviewThreadReply(pullRequestReviewID string, pullRequestReviewThreadID string, body string) error
- func (client *Client) AddReaction(subjectID string, content ReactionContent) error
- func (client *Client) ApprovePullRequest(repository string, number int) error
- func (client *Client) CommentOnPullRequest(repository string, number int, body string) error
- func (client *Client) ConvertPullRequestToDraft(repository string, number int) error
- func (client *Client) DeletePullRequestReviewComment(commentID string) error
- func (client *Client) EditPullRequestDescription(repository string, number int, body string) error
- func (client *Client) EditPullRequestTitle(repository string, number int, title string) error
- func (client *Client) GetConnectedUser() (ConnectedUser, error)
- func (client *Client) GetIssueDetail(repository string, number int) (IssueDetail, error)
- func (client *Client) GetPendingPullRequestReviewID(repository string, number int) (string, bool, error)
- func (client *Client) GetPullRequestBuildInfo(repository string, number int, check PullRequestStatusCheck) (PullRequestBuildInfo, error)
- func (client *Client) GetPullRequestBuildRun(repository string, check PullRequestStatusCheck) (string, error)
- func (client *Client) GetPullRequestBuildRunJobLog(repository string, jobDatabaseID int) (string, error)
- func (client *Client) GetPullRequestBuildRunJobLogForCheck(repository string, check PullRequestStatusCheck) (PullRequestBuildRunJob, string, error)
- func (client *Client) GetPullRequestBuildRunJobs(repository string, check PullRequestStatusCheck) ([]PullRequestBuildRunJob, error)
- func (client *Client) GetPullRequestDetail(repository string, number int) (PullRequestDetail, error)
- func (client *Client) GetPullRequestDiff(repository string, number int) (PullRequestDiff, error)
- func (client *Client) GetReleaseDetail(repository string, id int) (ReleaseDetail, error)
- func (client *Client) ListAssignableUsers(repository string) ([]PullRequestAuthor, error)
- func (client *Client) ListNotifications() ([]Notification, error)
- func (client *Client) ListPullRequests(commandArguments []string) ([]PullRequest, error)
- func (client *Client) MarkAllNotificationsDone(notifications []Notification) (int, error)
- func (client *Client) MarkAllNotificationsRead() (NotificationBulkReadResult, error)
- func (client *Client) MarkNotificationDone(threadID string) error
- func (client *Client) MarkNotificationRead(threadID string) error
- func (client *Client) MarkPullRequestReadyForReview(repository string, number int) error
- func (client *Client) OpenPullRequestInBrowser(repository string, number int) error
- func (client *Client) RemoveReaction(subjectID string, content ReactionContent) error
- func (client *Client) RequestChangesOnPullRequest(repository string, number int, body string) error
- func (client *Client) ResolvePullRequestReviewThread(threadID string) error
- func (client *Client) ReviewPullRequestWithComment(repository string, number int, body string) error
- func (client *Client) SquashMergePullRequest(repository string, number int) error
- func (client *Client) StartPendingPullRequestReview(repository string, number int) (string, error)
- func (client *Client) SubmitPullRequestReview(pullRequestReviewID string, event PullRequestReviewEvent, body string) error
- func (client *Client) UnresolvePullRequestReviewThread(threadID string) error
- func (client *Client) UpdatePullRequestAssignees(repository string, number int, addLogins []string, removeLogins []string) error
- func (client *Client) UpdatePullRequestReviewComment(commentID string, body string) error
- type CommandResult
- type ConnectedUser
- type IssueDetail
- type Notification
- type NotificationBulkReadResult
- type NotificationSubject
- type PullRequest
- type PullRequestAuthor
- type PullRequestBuildInfo
- type PullRequestBuildRunJob
- type PullRequestComment
- type PullRequestCommentAuthor
- type PullRequestCommit
- type PullRequestCommitAuthor
- type PullRequestDetail
- type PullRequestDiff
- type PullRequestDiffFile
- type PullRequestInlineComment
- type PullRequestLabel
- type PullRequestRequestedReviewer
- type PullRequestReview
- type PullRequestReviewEvent
- type PullRequestReviewRequest
- type PullRequestReviewRequestOrganization
- type PullRequestReviewThread
- type PullRequestReviewThreadTarget
- type PullRequestStatusCheck
- type ReactionContent
- type ReactionGroup
- type ReleaseDetail
- type Repository
- type Runner
Constants ¶
View Source
const ( NotificationSubjectTypePullRequest = "PullRequest" NotificationSubjectTypeIssue = "Issue" NotificationSubjectTypeRelease = "Release" )
Variables ¶
View Source
var ( ErrUnauthenticated = errors.New("gh is not authenticated") ErrInvalidConnectedUserResponse = errors.New("invalid connected user response") ErrEmptyConnectedUser = errors.New("empty connected user response") )
View Source
var ( ErrInvalidNotificationResponse = fmt.Errorf("invalid notification response") ErrInvalidIssueDetailResponse = fmt.Errorf("invalid issue detail response") ErrInvalidReleaseDetailResponse = fmt.Errorf("invalid release detail response") ErrMissingNotificationSubjectTarget = fmt.Errorf("missing notification subject target") )
View Source
var ( ErrMissingNotificationThreadID = errors.New("missing notification thread id") ErrNotificationEndpointAuthRefused = errors.New("notification endpoint authentication refused") )
View Source
var ( ErrInvalidPullRequestBuildResponse = errors.New("invalid pull request build response") ErrPullRequestBuildInfoNotFound = errors.New("pull request build info not found") )
View Source
var ( ErrMissingPullRequestIdentity = errors.New("missing pull request identity") ErrEmptyPullRequestComment = errors.New("empty pull request comment") )
View Source
var ( ErrInvalidPullRequestDetailResponse = fmt.Errorf("invalid pull request detail response") ErrInvalidPullRequestInlineCommentResponse = fmt.Errorf("invalid pull request inline comment response") )
View Source
var ( ErrInvalidReactionTarget = errors.New("invalid reaction target") ErrInvalidReactionContent = errors.New("invalid reaction content") ErrInvalidReactionResponse = errors.New("invalid reaction response") )
View Source
var ( ErrInvalidPullRequestReactionTargetsResponse = fmt.Errorf("invalid pull request reaction targets response") ErrInvalidPullRequestReviewCommentReactionGroupsPayload = fmt.Errorf("invalid pull request review comment reaction groups response") )
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 ( ErrInvalidPullRequestResponse = fmt.Errorf("invalid pull request response") ErrInvalidPullRequestReviewMetadataResponse = fmt.Errorf("invalid pull request review metadata response") )
View Source
var ErrEmptyPullRequestReviewBody = errors.New("empty pull request review body")
View Source
var ErrEmptyPullRequestTitle = errors.New("empty pull request title")
View Source
var ErrInvalidAssignableUsersResponse = fmt.Errorf("invalid assignable users response")
View Source
var ErrInvalidPendingPullRequestReviewResponse = errors.New("invalid pending pull request review response")
View Source
var ErrInvalidPullRequestDiffFilesResponse = fmt.Errorf("invalid pull request diff files response")
View Source
var ErrInvalidPullRequestReviewCommentMutation = errors.New("invalid pull request review comment mutation")
View Source
var ErrInvalidPullRequestReviewSubmission = errors.New("invalid pull request review submission")
View Source
var ErrInvalidPullRequestReviewThreadMutation = errors.New("invalid pull request review thread mutation")
View Source
var ErrInvalidPullRequestReviewThreadReply = errors.New("invalid pull request review thread reply")
View Source
var ErrInvalidPullRequestReviewThreadResponse = errors.New("invalid pull request review thread response")
View Source
var ErrInvalidPullRequestReviewThreadTarget = errors.New("invalid pull request review thread target")
View Source
var ErrInvalidPullRequestReviewThreadsResponse = fmt.Errorf("invalid pull request review threads response")
View Source
var ErrInvalidPullRequestURL = errors.New("invalid GitHub pull request URL")
View Source
var ErrInvalidSubmittedPullRequestReviewResponse = errors.New("invalid submitted pull request review response")
View Source
var SupportedReactionContents = []ReactionContent{ ReactionContentThumbsUp, ReactionContentThumbsDown, ReactionContentLaugh, ReactionContentHooray, ReactionContentConfused, ReactionContentHeart, ReactionContentRocket, ReactionContentEyes, }
Functions ¶
func FormatPullRequestBuildRunCommand ¶
func FormatPullRequestBuildRunCommand(repository string, check PullRequestStatusCheck) string
func FormatPullRequestBuildRunJobsCommand ¶
func FormatPullRequestBuildRunJobsCommand(repository string, check PullRequestStatusCheck) string
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithRunner ¶
func (*Client) AddPullRequestReviewThread ¶
func (client *Client) AddPullRequestReviewThread(pullRequestReviewID string, body string, target PullRequestReviewThreadTarget) error
func (*Client) AddPullRequestReviewThreadReply ¶
func (*Client) AddReaction ¶
func (client *Client) AddReaction(subjectID string, content ReactionContent) error
func (*Client) ApprovePullRequest ¶
func (*Client) CommentOnPullRequest ¶
func (*Client) ConvertPullRequestToDraft ¶
func (*Client) DeletePullRequestReviewComment ¶
func (*Client) EditPullRequestDescription ¶
func (*Client) EditPullRequestTitle ¶
func (*Client) GetConnectedUser ¶
func (client *Client) GetConnectedUser() (ConnectedUser, error)
func (*Client) GetIssueDetail ¶
func (client *Client) GetIssueDetail(repository string, number int) (IssueDetail, error)
func (*Client) GetPendingPullRequestReviewID ¶
func (*Client) GetPullRequestBuildInfo ¶
func (client *Client) GetPullRequestBuildInfo(repository string, number int, check PullRequestStatusCheck) (PullRequestBuildInfo, error)
func (*Client) GetPullRequestBuildRun ¶
func (client *Client) GetPullRequestBuildRun(repository string, check PullRequestStatusCheck) (string, error)
func (*Client) GetPullRequestBuildRunJobLog ¶
func (*Client) GetPullRequestBuildRunJobLogForCheck ¶
func (client *Client) GetPullRequestBuildRunJobLogForCheck(repository string, check PullRequestStatusCheck) (PullRequestBuildRunJob, string, error)
func (*Client) GetPullRequestBuildRunJobs ¶
func (client *Client) GetPullRequestBuildRunJobs(repository string, check PullRequestStatusCheck) ([]PullRequestBuildRunJob, error)
func (*Client) GetPullRequestDetail ¶
func (client *Client) GetPullRequestDetail(repository string, number int) (PullRequestDetail, error)
func (*Client) GetPullRequestDiff ¶
func (client *Client) GetPullRequestDiff(repository string, number int) (PullRequestDiff, error)
func (*Client) GetReleaseDetail ¶
func (client *Client) GetReleaseDetail(repository string, id int) (ReleaseDetail, error)
func (*Client) ListAssignableUsers ¶
func (client *Client) ListAssignableUsers(repository string) ([]PullRequestAuthor, error)
func (*Client) ListNotifications ¶
func (client *Client) ListNotifications() ([]Notification, error)
func (*Client) ListPullRequests ¶
func (client *Client) ListPullRequests(commandArguments []string) ([]PullRequest, error)
func (*Client) MarkAllNotificationsDone ¶
func (client *Client) MarkAllNotificationsDone(notifications []Notification) (int, error)
func (*Client) MarkAllNotificationsRead ¶
func (client *Client) MarkAllNotificationsRead() (NotificationBulkReadResult, error)
func (*Client) MarkNotificationDone ¶
func (*Client) MarkNotificationRead ¶
func (*Client) MarkPullRequestReadyForReview ¶
func (*Client) OpenPullRequestInBrowser ¶
func (*Client) RemoveReaction ¶
func (client *Client) RemoveReaction(subjectID string, content ReactionContent) error
func (*Client) RequestChangesOnPullRequest ¶
func (*Client) ResolvePullRequestReviewThread ¶
func (*Client) ReviewPullRequestWithComment ¶
func (*Client) SquashMergePullRequest ¶
func (*Client) StartPendingPullRequestReview ¶
func (*Client) SubmitPullRequestReview ¶
func (client *Client) SubmitPullRequestReview(pullRequestReviewID string, event PullRequestReviewEvent, body string) error
func (*Client) UnresolvePullRequestReviewThread ¶
func (*Client) UpdatePullRequestAssignees ¶
type CommandResult ¶
type ConnectedUser ¶
type IssueDetail ¶
type IssueDetail struct {
Title string `json:"title"`
Number int `json:"number"`
URL string `json:"html_url"`
Body string `json:"body"`
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 Repository `json:"repository"`
Subject NotificationSubject `json:"subject"`
}
func (Notification) IssueIdentity ¶
func (notification Notification) IssueIdentity() (string, int, bool)
func (Notification) PullRequestSummary ¶
func (notification Notification) PullRequestSummary() (PullRequest, bool)
func (Notification) ReleaseIdentity ¶
func (notification Notification) ReleaseIdentity() (string, int, bool)
type NotificationBulkReadResult ¶
type NotificationBulkReadResult struct {
Accepted bool
}
type NotificationSubject ¶
type PullRequest ¶
type PullRequest struct {
ID string `json:"id"`
Title string `json:"title"`
Number int `json:"number"`
Repository Repository `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"`
StatusCheckRollupState string `json:"statusCheckRollupState"`
}
func ParsePullRequestURL ¶
func ParsePullRequestURL(raw string) (PullRequest, error)
type PullRequestAuthor ¶
type PullRequestBuildInfo ¶
type PullRequestBuildInfo struct {
Bucket string `json:"bucket"`
CompletedAt string `json:"completedAt"`
Description string `json:"description"`
Event string `json:"event"`
Link string `json:"link"`
Name string `json:"name"`
StartedAt string `json:"startedAt"`
State string `json:"state"`
Workflow string `json:"workflow"`
}
type PullRequestBuildRunJob ¶
type PullRequestComment ¶
type PullRequestComment struct {
ID string `json:"id"`
Author *PullRequestCommentAuthor `json:"author"`
Body string `json:"body"`
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 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"`
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"`
ReviewRequests []PullRequestReviewRequest `json:"reviewRequests"`
BaseRefName string `json:"baseRefName"`
HeadRefName string `json:"headRefName"`
MergeStateStatus string `json:"mergeStateStatus"`
Mergeable string `json:"mergeable"`
ReactionGroups []ReactionGroup `json:"reactionGroups,omitempty"`
Comments []PullRequestComment `json:"comments"`
Commits []PullRequestCommit `json:"commits"`
Reviews []PullRequestReview `json:"reviews"`
InlineComments []PullRequestInlineComment `json:"-"`
InlineCommentThreads []PullRequestReviewThread `json:"-"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
ChangedFiles int `json:"changedFiles"`
StatusCheckRollup []PullRequestStatusCheck `json:"statusCheckRollup"`
}
type PullRequestDiff ¶
type PullRequestDiff struct {
UnifiedDiff string
Files []PullRequestDiffFile
Threads []PullRequestReviewThread
}
type PullRequestDiffFile ¶
type PullRequestInlineComment ¶
type PullRequestInlineComment struct {
ID string `json:"node_id"`
Author *PullRequestCommentAuthor `json:"user"`
Body string `json:"body"`
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 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 {
Author *PullRequestCommentAuthor `json:"author"`
State string `json:"state"`
SubmittedAt string `json:"submittedAt"`
}
type PullRequestReviewEvent ¶
type PullRequestReviewEvent string
const ( PullRequestReviewEventComment PullRequestReviewEvent = "COMMENT" PullRequestReviewEventApprove PullRequestReviewEvent = "APPROVE" PullRequestReviewEventRequestChanges PullRequestReviewEvent = "REQUEST_CHANGES" )
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 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 PullRequestStatusCheck ¶
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" )
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"`
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 ¶
func (*Repository) UnmarshalJSON ¶
func (repository *Repository) UnmarshalJSON(data []byte) error
Source Files
¶
- client.go
- command_runner.go
- doc.go
- notification.go
- notification_mutation.go
- pending_pull_request_review.go
- pending_pull_request_review_submit.go
- pull_request_action.go
- pull_request_assignee.go
- pull_request_browser.go
- pull_request_build.go
- pull_request_comment.go
- pull_request_detail.go
- pull_request_diff.go
- pull_request_edit.go
- pull_request_reaction_mutation.go
- pull_request_reaction_targets.go
- pull_request_review.go
- pull_request_review_comment_mutation.go
- pull_request_review_thread.go
- pull_request_review_thread_reply.go
- pull_request_review_thread_resolution.go
- pull_request_review_threads.go
- pull_request_run.go
- pull_request_stage_merge.go
- pull_request_url.go
- pull_requests.go
- reaction.go
Click to show internal directories.
Click to hide internal directories.