Documentation
¶
Index ¶
- func CreatePR(head, base, title, body string, draft bool, labels []string) (string, error)
- func GetDefaultMergeMethod() (string, error)
- func IsAvailable() bool
- func MergePR(prNumber int, method string) error
- func RepoSlug() (string, error)
- func ResetAvailability()
- type CISummary
- type PR
- type PRDetail
- type PRDetails
- type PRInfo
- type PRLabel
- type Review
- type ReviewItem
- type ReviewRequest
- type ReviewSummary
- type StatusCheckRun
- type WatchStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultMergeMethod ¶ added in v1.13.0
GetDefaultMergeMethod returns the preferred merge method for the repo. Picks the first enabled method in order: squash → merge → rebase.
func MergePR ¶ added in v1.13.0
MergePR merges a pull request using the given method (squash, merge, rebase).
func ResetAvailability ¶ added in v1.6.0
func ResetAvailability()
ResetAvailability resets the cached gh availability check. Intended for testing only.
Types ¶
type PR ¶
type PR struct {
Number int `json:"number"`
HeadRefName string `json:"headRefName"`
State string `json:"state"`
ReviewRequests []ReviewRequest `json:"reviewRequests"`
LatestReviews []Review `json:"latestReviews"`
StatusChecks []StatusCheckRun `json:"statusCheckRollup"`
}
PR represents a GitHub pull request.
func FindPRForBranch ¶
FindPRForBranch returns the first PR matching the branch name and state.
func GetPRForBranch ¶
GetPRForBranch fetches the PR for a specific branch. Returns (nil, nil) if gh is not available or no PR exists.
func (*PR) GetCISummary ¶
GetCISummary computes CI check state counts.
func (*PR) GetReviewSummary ¶
func (pr *PR) GetReviewSummary() ReviewSummary
GetReviewSummary computes review state counts.
type PRDetail ¶ added in v1.19.0
type PRDetail struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
Author struct {
Login string `json:"login"`
} `json:"author"`
StatusChecks []StatusCheckRun `json:"statusCheckRollup"`
}
PRDetail is the rich PR info used by the dashboard detail panel. Fetched on demand — kept separate from the lighter `PR` returned by ListPRs.
func GetPRDetail ¶ added in v1.19.0
GetPRDetail fetches title/body/author and named CI checks for one PR in a single gh call. Returns (nil, nil) when gh isn't installed.
type PRDetails ¶
type PRDetails struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
BaseRefName string `json:"baseRefName"`
IsDraft bool `json:"isDraft"`
Labels []PRLabel `json:"labels"`
}
PRDetails holds full PR metadata for recreation after branch rename.
func GetPRDetails ¶
GetPRDetails fetches full details for the open PR on a branch.
type PRInfo ¶ added in v1.8.0
type PRInfo struct {
Number int `json:"number"`
Title string `json:"title"`
HeadRefName string `json:"headRefName"`
State string `json:"state"`
}
PRInfo holds lightweight PR metadata for checkout.
func GetPRByNumber ¶ added in v1.8.0
GetPRByNumber fetches PR metadata by number.
type PRLabel ¶
type PRLabel struct {
Name string `json:"name"`
}
PRLabel represents a label on a PR.
type Review ¶
type Review struct {
Author struct {
Login string `json:"login"`
} `json:"author"`
State string `json:"state"` // APPROVED, CHANGES_REQUESTED, COMMENTED
}
Review represents a completed review.
type ReviewItem ¶ added in v1.3.0
ReviewItem represents a unified review entry (completed or pending).
type ReviewRequest ¶
type ReviewRequest struct {
Login string `json:"login"`
}
ReviewRequest represents a pending review request.
type ReviewSummary ¶
ReviewSummary aggregates review counts.
type StatusCheckRun ¶
type StatusCheckRun struct {
Name string `json:"name"`
State string `json:"state"` // SUCCESS, FAILURE, PENDING, etc.
Conclusion string `json:"conclusion"` // SUCCESS, FAILURE, SKIPPED, TIMED_OUT, CANCELLED, ""
}
StatusCheckRun represents a CI check.
func (StatusCheckRun) Result ¶ added in v1.9.2
func (c StatusCheckRun) Result() string
Result classifies a CI check as "pass", "fail", or "pending".
type WatchStatus ¶
type WatchStatus struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"` // OPEN, CLOSED, MERGED
HeadRefName string `json:"headRefName"`
MergeStateStatus string `json:"mergeStateStatus"` // CLEAN, BLOCKED, BEHIND, DRAFT, DIRTY, UNKNOWN
Mergeable string `json:"mergeable"` // MERGEABLE, CONFLICTING, UNKNOWN
ReviewDecision string `json:"reviewDecision"` // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, ""
ReviewRequests []ReviewRequest `json:"reviewRequests"`
LatestReviews []Review `json:"latestReviews"`
StatusChecks []StatusCheckRun `json:"statusCheckRollup"`
}
WatchStatus holds detailed PR state from `gh pr view`, including fields not available from `gh pr list` (mergeStateStatus, mergeable).
func GetWatchStatus ¶
func GetWatchStatus(branch string) (*WatchStatus, error)
GetWatchStatus fetches detailed PR status for a branch using `gh pr view`.
func (*WatchStatus) ChecksByStatus ¶ added in v1.3.0
func (ws *WatchStatus) ChecksByStatus() (pass, fail, pending []StatusCheckRun)
ChecksByStatus returns checks sorted into pass, fail, and pending buckets. Checks with empty names (GitHub summary checks) are excluded.
func (*WatchStatus) FailedCheckNames ¶
func (ws *WatchStatus) FailedCheckNames() []string
FailedCheckNames returns the names of checks that failed.
func (*WatchStatus) GetCISummary ¶
func (ws *WatchStatus) GetCISummary() CISummary
GetCISummary computes CI check state counts for a WatchStatus.
func (*WatchStatus) GetReviewSummary ¶
func (ws *WatchStatus) GetReviewSummary() ReviewSummary
GetReviewSummary computes review state counts for a WatchStatus.
func (*WatchStatus) ReviewItems ¶ added in v1.3.0
func (ws *WatchStatus) ReviewItems() []ReviewItem
ReviewItems merges LatestReviews and ReviewRequests into a unified list. A pending re-review request supersedes any previous completed review (the old approval is stale after new commits are pushed).