Documentation
¶
Index ¶
- Variables
- func CanPushToRepo(repoOwner, repoName, username string) bool
- func CheckAuth() error
- func GetCurrentUser() (string, error)
- type CheckStatus
- type Client
- func (c *Client) CreatePR(title, body, head, base string, draft bool) (*PR, error)
- func (c *Client) GetPR(number int) (*PR, error)
- func (c *Client) GetPRByBranch(branch string) (*PR, error)
- func (c *Client) GetPRChecks(number int) (*CheckStatus, error)
- func (c *Client) GetPRForkInfo(number int) (*PRForkInfo, error)
- func (c *Client) ListOpenPRs() ([]OpenPR, error)
- func (c *Client) MergePR(number int, method string, deleteRemoteBranch bool) error
- func (c *Client) SetPRDraft(number int) error
- func (c *Client) SetPRReady(number int) error
- func (c *Client) UpdatePR(number int, body string) error
- func (c *Client) UpdatePRBase(number int, base string) error
- func (c *Client) UpdateStackDescription(stack *config.Stack, currentBranch string) error
- func (c *Client) UpdateStackDescriptionCached(stack *config.Stack, currentBranch string, prMap map[int]*PR) error
- type OpenPR
- type PR
- type PRForkInfo
Constants ¶
This section is empty.
Variables ¶
var ErrPRNotFound = errors.New("no pull request found")
ErrPRNotFound is returned by GetPRByBranch when GitHub has no PR for the given head branch. Callers that want to distinguish "no PR" from "transient error" can use errors.Is(err, ErrPRNotFound) instead of fragile string matching against gh stderr.
Functions ¶
func CanPushToRepo ¶
CanPushToRepo checks whether the given GitHub user has push (write) access to a specific repository. Returns true if the user has write, maintain, or admin permission. Returns false if the user has no push access or if the API call fails (e.g., 403 means no push access).
func CheckAuth ¶
func CheckAuth() error
CheckAuth verifies that the gh CLI is authenticated and returns an error if not.
func GetCurrentUser ¶
GetCurrentUser returns the GitHub username of the currently authenticated user.
Types ¶
type CheckStatus ¶
type CheckStatus struct {
State string // "success", "failure", "pending", "error"
Summary string // e.g., "3/3 checks passed"
}
CheckStatus represents CI check status
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps GitHub operations using gh CLI
func NewClient ¶
NewClient creates a new GitHub client by parsing the remote URL. Accepts SSH, HTTPS, ssh://, and git:// URLs against github.com — including URLs that carry a port (`https://github.com:443/...`), a query / anchor suffix (`...?ref=…`, `...#readme`), or a `.git` suffix in any case. Returns an error for non-github.com hosts and for malformed inputs.
func (*Client) GetPRByBranch ¶
GetPRByBranch gets a PR by its head branch name
func (*Client) GetPRChecks ¶
func (c *Client) GetPRChecks(number int) (*CheckStatus, error)
GetPRChecks gets the CI check status for a PR
func (*Client) GetPRForkInfo ¶
func (c *Client) GetPRForkInfo(number int) (*PRForkInfo, error)
GetPRForkInfo fetches fork-related metadata for a PR. Returns info about whether the PR is from a fork and whether maintainers can push.
func (*Client) ListOpenPRs ¶
ListOpenPRs returns all open PRs in the repository
func (*Client) MergePR ¶
MergePR merges a pull request using the specified method (merge, squash, rebase)
func (*Client) SetPRDraft ¶
SetPRDraft marks a PR as draft
func (*Client) SetPRReady ¶
SetPRReady marks a draft PR as ready for review
func (*Client) UpdatePRBase ¶
UpdatePRBase updates a PR's base branch
func (*Client) UpdateStackDescription ¶
UpdateStackDescription updates PR descriptions with stack info.
type OpenPR ¶
type OpenPR struct {
Number int `json:"number"`
Title string `json:"title"`
Branch string `json:"headRefName"`
Author string `json:"author"`
URL string `json:"url"`
}
OpenPR represents a minimal PR for listing
type PR ¶
type PR struct {
Number int `json:"number"`
URL string `json:"url"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
Base string `json:"baseRefName"`
Head string `json:"headRefName"`
MergedAt string `json:"mergedAt"` // non-empty if merged
Merged bool // computed from MergedAt
Mergeable string `json:"mergeable"`
IsDraft bool `json:"isDraft"`
ReviewState string `json:"reviewDecision"`
// Fork-related fields
HeadRepoOwner string `json:"headRepositoryOwner_login"` // set via custom parsing
HeadRepoName string `json:"headRepository_name"` // set via custom parsing
MaintainerCanModify bool // whether the repo maintainer can push to the fork's PR branch
IsFork bool // computed: true if head repo owner differs from base repo owner
}
PR represents a pull request
type PRForkInfo ¶
type PRForkInfo struct {
HeadRepoOwner string // GitHub username/org that owns the head (source) repo
HeadRepoName string // Name of the head repo
MaintainerCanModify bool // Whether the repo maintainer can push to the fork branch
IsFork bool // True if the PR is from a fork (head owner != base repo owner)
}
PRForkInfo contains fork-related information for a PR