Documentation
¶
Index ¶
- Variables
- func NewProvider(token string) globalEntities.ForgeProvider
- type Provider
- func (p *Provider) AuthToken() string
- func (p *Provider) CloneURL(repo globalEntities.Repository) string
- func (p *Provider) ConfigureTransport()
- func (p *Provider) CreateBranchWithChanges(ctx context.Context, repo globalEntities.Repository, ...) error
- func (p *Provider) CreatePullRequest(ctx context.Context, repo globalEntities.Repository, ...) (*globalEntities.PullRequest, error)
- func (p *Provider) DiscoverRepositories(ctx context.Context, org string) ([]globalEntities.Repository, error)
- func (p *Provider) GetAuthMethods(_ string) []transport.AuthMethod
- func (p *Provider) GetFileContent(ctx context.Context, repo globalEntities.Repository, path string) (string, error)
- func (p *Provider) GetPullRequestCheckStatus(ctx context.Context, repo globalEntities.Repository, prID int) (bool, error)
- func (p *Provider) GetPullRequestDiff(ctx context.Context, repo globalEntities.Repository, prID int) (string, error)
- func (p *Provider) GetPullRequestFiles(ctx context.Context, repo globalEntities.Repository, prID int) ([]globalEntities.PullRequestFile, error)
- func (p *Provider) GetPullRequestStatus(ctx context.Context, repo globalEntities.Repository, prID int) (string, error)
- func (p *Provider) GetServiceType() globalEntities.ServiceType
- func (p *Provider) GetTags(ctx context.Context, repo globalEntities.Repository) ([]string, error)
- func (p *Provider) HasFile(ctx context.Context, repo globalEntities.Repository, path string) bool
- func (p *Provider) ListFiles(ctx context.Context, repo globalEntities.Repository, pattern string) ([]globalEntities.File, error)
- func (p *Provider) ListOpenPullRequests(ctx context.Context, repo globalEntities.Repository) ([]globalEntities.PullRequestDetail, error)
- func (p *Provider) ListPullRequestComments(ctx context.Context, repo globalEntities.Repository, prID int) ([]globalEntities.PullRequestComment, error)
- func (p *Provider) MatchesURL(rawURL string) bool
- func (p *Provider) MergePullRequest(ctx context.Context, repo globalEntities.Repository, prID int, strategy string) error
- func (p *Provider) Name() string
- func (p *Provider) PostPullRequestComment(ctx context.Context, repo globalEntities.Repository, prID int, body string, ...) error
- func (p *Provider) PostPullRequestThreadComment(ctx context.Context, repo globalEntities.Repository, prID int, filePath string, ...) (int, error)
- func (p *Provider) PrepareCloneURL(url string) string
- func (p *Provider) PullRequestExists(ctx context.Context, repo globalEntities.Repository, sourceBranch string) (bool, error)
- func (p *Provider) SSHCloneURL(repo globalEntities.Repository, sshAlias string) string
- func (p *Provider) SubmitPullRequestReview(ctx context.Context, repo globalEntities.Repository, prID int, ...) error
- func (p *Provider) UpdatePullRequestThreadStatus(_ context.Context, _ globalEntities.Repository, _, _ int, _ string) error
Constants ¶
This section is empty.
Variables ¶
var ErrReviewBodyRequired = errors.New("review body is required for this verdict")
ErrReviewBodyRequired signals that SubmitPullRequestReview was called with a verdict GitHub mandates a body for (REQUEST_CHANGES, COMMENT) but the caller did not provide one. Returned up-front so callers see a deterministic error instead of an opaque HTTP 422 from GitHub.
var ErrThreadStatusUpdateUnsupported = errors.New(
"updating pull request thread status is not supported on GitHub",
)
ErrThreadStatusUpdateUnsupported is returned by the GitHub provider when callers attempt to update the status of a review thread. GitHub has no direct REST equivalent of Azure DevOps' thread status field; thread resolution is exposed only via the GraphQL resolveReviewThread mutation, which is not yet wired up.
Functions ¶
func NewProvider ¶
func NewProvider(token string) globalEntities.ForgeProvider
NewProvider creates a new GitHub provider with the given token.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements ForgeProvider, FileAccessProvider, and LocalGitAuthProvider for GitHub.
func (*Provider) CloneURL ¶
func (p *Provider) CloneURL(repo globalEntities.Repository) string
func (*Provider) ConfigureTransport ¶
func (p *Provider) ConfigureTransport()
func (*Provider) CreateBranchWithChanges ¶
func (p *Provider) CreateBranchWithChanges( ctx context.Context, repo globalEntities.Repository, input globalEntities.BranchInput, ) error
func (*Provider) CreatePullRequest ¶
func (p *Provider) CreatePullRequest( ctx context.Context, repo globalEntities.Repository, input globalEntities.PullRequestInput, ) (*globalEntities.PullRequest, error)
func (*Provider) DiscoverRepositories ¶
func (p *Provider) DiscoverRepositories( ctx context.Context, org string, ) ([]globalEntities.Repository, error)
func (*Provider) GetAuthMethods ¶
func (p *Provider) GetAuthMethods(_ string) []transport.AuthMethod
func (*Provider) GetFileContent ¶
func (p *Provider) GetFileContent( ctx context.Context, repo globalEntities.Repository, path string, ) (string, error)
func (*Provider) GetPullRequestCheckStatus ¶ added in v0.6.0
func (p *Provider) GetPullRequestCheckStatus( ctx context.Context, repo globalEntities.Repository, prID int, ) (bool, error)
func (*Provider) GetPullRequestDiff ¶
func (p *Provider) GetPullRequestDiff( ctx context.Context, repo globalEntities.Repository, prID int, ) (string, error)
func (*Provider) GetPullRequestFiles ¶
func (p *Provider) GetPullRequestFiles( ctx context.Context, repo globalEntities.Repository, prID int, ) ([]globalEntities.PullRequestFile, error)
func (*Provider) GetPullRequestStatus ¶ added in v1.0.0
func (p *Provider) GetPullRequestStatus( ctx context.Context, repo globalEntities.Repository, prID int, ) (string, error)
GetPullRequestStatus returns the GitHub pull request state. GitHub uses "open" or "closed" for `state`; closed PRs that were merged are reported as "merged" so callers can distinguish abandoned PRs from merged ones.
The merged signal is read off `merged_at` (`MergedAt`) rather than the `merged` boolean. The boolean is reliably set on the single-PR `GET /repos/.../pulls/{N}` response this method uses, but `merged_at` is the canonical timestamp populated whenever the PR was merged at any point — using the timestamp avoids a class of false negatives on fixture / replay payloads where `merged` is omitted (the Go client's `GetMerged()` returns the zero value for a missing field, which would silently report a merged PR as `closed`). Pinned per Copilot review on PR #86 thread `PRRT_kwDORQWb3M5-6QA0`.
func (*Provider) GetServiceType ¶
func (p *Provider) GetServiceType() globalEntities.ServiceType
func (*Provider) GetTags ¶
func (p *Provider) GetTags( ctx context.Context, repo globalEntities.Repository, ) ([]string, error)
func (*Provider) HasFile ¶
func (p *Provider) HasFile( ctx context.Context, repo globalEntities.Repository, path string, ) bool
func (*Provider) ListFiles ¶
func (p *Provider) ListFiles( ctx context.Context, repo globalEntities.Repository, pattern string, ) ([]globalEntities.File, error)
func (*Provider) ListOpenPullRequests ¶
func (p *Provider) ListOpenPullRequests( ctx context.Context, repo globalEntities.Repository, ) ([]globalEntities.PullRequestDetail, error)
func (*Provider) ListPullRequestComments ¶ added in v1.0.0
func (p *Provider) ListPullRequestComments( ctx context.Context, repo globalEntities.Repository, prID int, ) ([]globalEntities.PullRequestComment, error)
ListPullRequestComments returns every comment on the PR — both PR-wide "issue" comments (`GET /repos/.../issues/:n/comments`) and inline review comments (`GET /repos/.../pulls/:n/comments`). GitHub splits these across two endpoints so the implementation walks both, paginates each, and concatenates into the unified `PullRequestComment` shape.
PR-wide comments land with `FilePath`/`Line` zeroed and `ThreadID` zero (GitHub does not group issue comments into threads). Inline comments land with `FilePath` + `Line` populated and `ThreadID` set to the root comment's ID for that conversation — every reply on a GitHub review thread carries `in_reply_to_id` pointing at the top-level comment, so using `in_reply_to_id` (or the comment's own ID when it is the root) gives callers a stable per-thread handle for dedup and walk. Reusing `pull_request_review_id` for grouping would be wrong: that field is the review submission ID and a single review can scatter inline comments across multiple unrelated threads (different files / lines), so it would merge conversations the platform treats as distinct.
func (*Provider) MatchesURL ¶
func (*Provider) MergePullRequest ¶ added in v0.6.0
func (p *Provider) MergePullRequest( ctx context.Context, repo globalEntities.Repository, prID int, strategy string, ) error
func (*Provider) PostPullRequestComment ¶
func (p *Provider) PostPullRequestComment( ctx context.Context, repo globalEntities.Repository, prID int, body string, _ ...globalEntities.CommentOption, ) error
PostPullRequestComment posts an issue-level comment on the pull request via the Issues REST API. GitHub's REST surface does not expose a per-comment "thread status" field analogous to Azure DevOps, so any entities.WithThreadStatus value supplied by the caller is silently ignored here. The variadic argument exists purely so callers can write provider- agnostic code against the ReviewProvider interface.
func (*Provider) PostPullRequestThreadComment ¶
func (p *Provider) PostPullRequestThreadComment( ctx context.Context, repo globalEntities.Repository, prID int, filePath string, line int, body string, _ ...globalEntities.CommentOption, ) (int, error)
PostPullRequestThreadComment posts an inline review comment on a specific file and line via the GitHub Reviews REST API. GitHub does not expose a per-thread status field comparable to Azure DevOps, so any entities.WithThreadStatus value supplied by the caller is silently ignored here. The variadic argument exists purely so callers can write provider- agnostic code against the ReviewProvider interface.
func (*Provider) PrepareCloneURL ¶
func (*Provider) PullRequestExists ¶
func (p *Provider) PullRequestExists( ctx context.Context, repo globalEntities.Repository, sourceBranch string, ) (bool, error)
func (*Provider) SSHCloneURL ¶ added in v0.8.0
func (p *Provider) SSHCloneURL(repo globalEntities.Repository, sshAlias string) string
func (*Provider) SubmitPullRequestReview ¶ added in v1.0.0
func (p *Provider) SubmitPullRequestReview( ctx context.Context, repo globalEntities.Repository, prID int, sub globalEntities.ReviewSubmission, ) error
SubmitPullRequestReview records a native PR review on GitHub via the PullRequests.CreateReview endpoint so the verdict shows up in the platform's reviewer panel. The verdict is mapped to the GitHub `event` field per the table on the ReviewProvider interface; ReviewVerdictWaitingForAuthor has no native equivalent on GitHub and collapses to COMMENT (a soft signal that does not block the PR), mirroring the Azure DevOps mapping where the same verdict resolves to vote=-5 (reviewer signal, not a hard block).
A self-review attempt (the authenticated identity is the PR author) returns HTTP 422 from GitHub with a body whose `message` matches selfReviewErrFragment. That specific case is logged at warn level and swallowed so the caller's fallback comment path still has a chance to surface the verdict — failing the whole review here would cause silent regressions on bot-authored PRs (e.g. autobump runs). Any other 422 (missing fields, invalid PR state, etc.) is returned as a wrapped error so genuine validation failures stay visible.
A ReviewVerdictComment or ReviewVerdictWaitingForAuthor with an empty body is skipped without an API call: GitHub rejects empty COMMENT reviews with 422 ("Body is too short") and nothing meaningful would surface anyway. ReviewVerdictRequestChanges likewise requires a body — GitHub rejects an empty REQUEST_CHANGES with 422, so the caller is told up-front via ErrReviewBodyRequired instead of triggering a failed round-trip.
func (*Provider) UpdatePullRequestThreadStatus ¶ added in v1.0.0
func (p *Provider) UpdatePullRequestThreadStatus( _ context.Context, _ globalEntities.Repository, _, _ int, _ string, ) error
UpdatePullRequestThreadStatus is not supported on GitHub via the REST API. GitHub exposes thread resolution only through the GraphQL resolveReviewThread mutation; until that is wired up, this method always returns ErrThreadStatusUpdateUnsupported.