github

package
v0.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRDiscussionSourceIssueComment  = "issue_comment"
	PRDiscussionSourceReview        = "review"
	PRDiscussionSourceReviewComment = "review_comment"
)
View Source
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 CloneURL added in v0.50.0

func CloneURL(ghRepo string) (string, error)

func CloneURLForBase added in v0.50.0

func CloneURLForBase(ghRepo, rawBase string) (string, error)

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 GitAuthEnv(baseEnv []string, token string) []string

func GitAuthEnvForBase added in v0.50.0

func GitAuthEnvForBase(baseEnv []string, token, rawBase string) []string

func GitHubAPIBaseURL added in v0.50.0

func GitHubAPIBaseURL(rawBase string) (string, error)

func GitHubWebBaseURL added in v0.50.0

func GitHubWebBaseURL(rawBase string) (string, error)

func HostnameFromAPIBaseURL added in v0.50.0

func HostnameFromAPIBaseURL(apiBaseURL string) string

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

func ResolveAuthToken(ctx context.Context, token string, hostname ...string) string

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 (c *Client) IsPullRequestOpen(ctx context.Context, ghRepo string, prNumber int) (bool, error)

func (*Client) ListOpenPullRequests added in v0.50.0

func (c *Client) ListOpenPullRequests(ctx context.Context, ghRepo string, limit int) ([]OpenPullRequest, error)

func (*Client) ListOwnerRepos added in v0.50.0

func (c *Client) ListOwnerRepos(ctx context.Context, owner string, limit int) ([]string, error)

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 (c *Client) SetCommitStatus(ctx context.Context, ghRepo, sha, state, description string) error

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

type OpenPullRequest added in v0.50.0

type OpenPullRequest struct {
	Number      int
	HeadRefOID  string
	BaseRefName string
	HeadRefName string
	Title       string
	AuthorLogin string
}

type PRDiscussionComment added in v0.50.0

type PRDiscussionComment struct {
	Author    string
	Body      string
	Source    string
	Path      string
	Line      int
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL