Documentation
¶
Index ¶
- Constants
- func CloneURL(ghRepo string) (string, error)
- func CloneURLForBase(ghRepo, rawBase string) (string, error)
- func DefaultGitHubHost() string
- func EnvironmentToken() string
- func GitAuthEnv(baseEnv []string, token string) []string
- func GitAuthEnvForBase(baseEnv []string, token, rawBase string) []string
- func GitHubAPIBaseURL(rawBase string) (string, error)
- func GitHubWebBaseURL(rawBase string) (string, error)
- func HostnameFromAPIBaseURL(apiBaseURL string) string
- func ResolveAuthToken(ctx context.Context, token string, hostname ...string) string
- type Client
- func (c *Client) CreatePRComment(ctx context.Context, ghRepo string, prNumber int, body string) error
- func (c *Client) FindExistingComment(ctx context.Context, ghRepo string, prNumber int) (int64, error)
- func (c *Client) IsPullRequestOpen(ctx context.Context, ghRepo string, prNumber int) (bool, error)
- func (c *Client) ListOpenPullRequests(ctx context.Context, ghRepo string, limit int) ([]OpenPullRequest, error)
- func (c *Client) ListOwnerRepos(ctx context.Context, owner string, limit int) ([]string, error)
- func (c *Client) ListPRDiscussionComments(ctx context.Context, ghRepo string, prNumber int) ([]PRDiscussionComment, error)
- func (c *Client) ListTrustedRepoCollaborators(ctx context.Context, ghRepo string) (map[string]struct{}, error)
- func (c *Client) SetCommitStatus(ctx context.Context, ghRepo, sha, state, description string) error
- func (c *Client) UpsertPRComment(ctx context.Context, ghRepo string, prNumber int, body string) error
- type ClientOption
- type OpenPullRequest
- type PRDiscussionComment
Constants ¶
const ( PRDiscussionSourceIssueComment = "issue_comment" PRDiscussionSourceReview = "review" PRDiscussionSourceReviewComment = "review_comment" )
const CommentMarker = "<!-- roborev-pr-comment -->"
CommentMarker is an invisible HTML marker embedded in every roborev PR comment so subsequent runs can find and update the existing comment instead of creating duplicates.
Variables ¶
This section is empty.
Functions ¶
func CloneURLForBase ¶ added in v0.50.0
func DefaultGitHubHost ¶ added in v0.50.0
func DefaultGitHubHost() string
DefaultGitHubHost returns the GitHub hostname from GH_HOST, or "github.com" when unset. Callers can pass the result to ResolveAuthToken so the gh CLI fallback targets the correct host.
func EnvironmentToken ¶ added in v0.50.0
func EnvironmentToken() string
func GitAuthEnv ¶ added in v0.50.0
func GitAuthEnvForBase ¶ added in v0.50.0
func GitHubAPIBaseURL ¶ added in v0.50.0
func GitHubWebBaseURL ¶ added in v0.50.0
func HostnameFromAPIBaseURL ¶ added in v0.50.0
HostnameFromAPIBaseURL extracts the hostname from a resolved API base URL (e.g., "https://api.github.com/" → "github.com", "https://ghe.example.com/api/v3/" → "ghe.example.com"). Falls back to DefaultGitHubHost when the URL is empty or unparseable.
func ResolveAuthToken ¶ added in v0.50.0
ResolveAuthToken returns the first non-empty token from: the provided token, GH_TOKEN/GITHUB_TOKEN env vars (via EnvironmentToken), or `gh auth token`. When hostname is provided and is not "github.com", the gh CLI fallback uses `--hostname` to request the correct token for GitHub Enterprise instances.
Types ¶
type Client ¶ added in v0.50.0
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.50.0
func NewClient(token string, opts ...ClientOption) (*Client, error)
func (*Client) CreatePRComment ¶ added in v0.50.0
func (c *Client) CreatePRComment(ctx context.Context, ghRepo string, prNumber int, body string) error
CreatePRComment posts a new roborev PR comment. It prepends the CommentMarker and truncates to review.MaxCommentLen, then always creates a new comment (no find/patch).
func (*Client) FindExistingComment ¶ added in v0.50.0
func (c *Client) FindExistingComment(ctx context.Context, ghRepo string, prNumber int) (int64, error)
FindExistingComment searches for an existing roborev comment on the given PR. It returns the comment ID if found, or 0 if no match exists.
func (*Client) IsPullRequestOpen ¶ added in v0.50.0
func (*Client) ListOpenPullRequests ¶ added in v0.50.0
func (*Client) ListOwnerRepos ¶ added in v0.50.0
func (*Client) ListPRDiscussionComments ¶ added in v0.50.0
func (c *Client) ListPRDiscussionComments(ctx context.Context, ghRepo string, prNumber int) ([]PRDiscussionComment, error)
ListPRDiscussionComments returns human-authored pull request discussion comments across top-level issue comments, review summaries, and inline review comments. Results are sorted oldest-first.
func (*Client) ListTrustedRepoCollaborators ¶ added in v0.50.0
func (c *Client) ListTrustedRepoCollaborators(ctx context.Context, ghRepo string) (map[string]struct{}, error)
ListTrustedRepoCollaborators returns collaborator logins that have effective maintain or admin access to the repository. Logins are normalized to lower case for case-insensitive matching against GitHub comment authors.
func (*Client) SetCommitStatus ¶ added in v0.50.0
func (*Client) UpsertPRComment ¶ added in v0.50.0
func (c *Client) UpsertPRComment(ctx context.Context, ghRepo string, prNumber int, body string) error
UpsertPRComment creates or updates a roborev PR comment. It prepends the CommentMarker, truncates to review.MaxCommentLen, and either patches an existing comment or creates a new one.
type ClientOption ¶ added in v0.50.0
type ClientOption func(*clientOptions) error
func WithBaseURL ¶ added in v0.50.0
func WithBaseURL(raw string) ClientOption
func WithHTTPClient ¶ added in v0.50.0
func WithHTTPClient(httpClient *http.Client) ClientOption