Documentation
¶
Overview ¶
Package github provides a lightweight GitHub REST API client for cloop. It supports issue sync, PR listing, and comment creation without requiring external dependencies beyond the standard library.
Index ¶
- func CheckRunSummary(runs []CheckRun) string
- func DetectRepo() (string, error)
- func ParseRepoFromRemote(remote string) (string, error)
- type CheckRun
- type CheckRunsResponse
- type Client
- func (c *Client) AddComment(number int, body string) error
- func (c *Client) CloseIssue(number int) error
- func (c *Client) CreateIssue(title, body string, labels []string) (*Issue, error)
- func (c *Client) CreatePR(head, base, title, body string, draft bool) (*PR, error)
- func (c *Client) CreateRelease(tagName, name, body string, draft bool) (*GHRelease, error)
- func (c *Client) GetIssue(number int) (*Issue, error)
- func (c *Client) GetPRFiles(number int) ([]PRFile, error)
- func (c *Client) ListCheckRuns(sha string) ([]CheckRun, error)
- func (c *Client) ListIssues(state string, labels []string) ([]Issue, error)
- func (c *Client) ListPRs(state string) ([]PR, error)
- func (c *Client) UpdateIssue(number int, updates map[string]interface{}) error
- type GHMilestone
- type GHRelease
- type Issue
- type Label
- type PR
- type PRFile
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRunSummary ¶
CheckRunSummary returns a one-line summary of check run results.
func DetectRepo ¶
DetectRepo tries to discover the owner/repo from the git remote in the current directory. It returns "owner/repo" or an error if not detectable.
func ParseRepoFromRemote ¶
ParseRepoFromRemote extracts "owner/repo" from a GitHub remote URL. Handles HTTPS (https://github.com/owner/repo.git) and SSH (git@github.com:owner/repo.git).
Types ¶
type CheckRun ¶
type CheckRun struct {
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
HTMLURL string `json:"html_url"`
}
CheckRun represents a CI check result.
type CheckRunsResponse ¶
type CheckRunsResponse struct {
CheckRuns []CheckRun `json:"check_runs"`
}
CheckRunsResponse is the GitHub API response for check runs.
type Client ¶
type Client struct {
Token string
Repo string // owner/repo
BaseURL string // default: https://api.github.com
}
Client is a minimal GitHub REST API client.
func (*Client) AddComment ¶
AddComment adds a comment to an issue or PR.
func (*Client) CloseIssue ¶
CloseIssue closes an issue by number.
func (*Client) CreateIssue ¶
CreateIssue creates a new issue and returns it.
func (*Client) CreatePR ¶
CreatePR creates a new pull request and returns it. head is the branch containing the changes (e.g. "feature/my-branch"). base is the branch the PR should merge into (e.g. "main").
func (*Client) CreateRelease ¶
CreateRelease creates a GitHub release for the given tag. tagName is the git tag (e.g. "v1.2.3"), name is the release title, body is the markdown release notes. Set draft=false to publish immediately.
func (*Client) GetPRFiles ¶
GetPRFiles returns the list of files changed in a pull request.
func (*Client) ListCheckRuns ¶
ListCheckRuns returns CI check runs for a commit SHA.
func (*Client) ListIssues ¶
ListIssues fetches issues from the repository. state: "open", "closed", or "all" labels: filter by label names (empty = no filter)
type GHMilestone ¶
type GHMilestone struct {
Title string `json:"title"`
}
GHMilestone represents a GitHub milestone attached to an issue.
type GHRelease ¶
type GHRelease struct {
ID int `json:"id"`
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
HTMLURL string `json:"html_url"`
Draft bool `json:"draft"`
}
GHRelease represents a GitHub release.
type Issue ¶
type Issue struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
Labels []Label `json:"labels"`
Assignees []User `json:"assignees"`
Milestone *GHMilestone `json:"milestone"`
UpdatedAt time.Time `json:"updated_at"`
// PullRequest is non-nil when this is actually a PR (issues endpoint returns both).
PullRequest *struct{} `json:"pull_request,omitempty"`
}
Issue represents a GitHub issue.
func (*Issue) LabelNames ¶
LabelNames returns a comma-separated list of label names.
type PR ¶
type PR struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"`
Draft bool `json:"draft"`
HTMLURL string `json:"html_url"`
User User `json:"user"`
Labels []Label `json:"labels"`
Head struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
} `json:"head"`
Base struct {
Ref string `json:"ref"`
} `json:"base"`
UpdatedAt time.Time `json:"updated_at"`
Body string `json:"body"`
}
PR represents a GitHub pull request.
func (*PR) LabelNames ¶
LabelNames returns a comma-separated list of label names for a PR.