github

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package github implements the GitHub Provider for the go-git-platform.

It builds on top of the official google/go-github SDK and adds the transport-layer cross-cutting behavior (auth, retry, hooks, logging) provided by the parent project's transport package. All Provider methods are split across the per-responsibility files in this package:

  • github.go: constructor, registration, identity (Platform, TestConnection)
  • repos.go: ListRepos, GetRepo, CreateRepo, DeleteRepo, UpdateRepo, ForkRepo
  • crs.go: Change requests (PRs): Create/Get/List/Close/Merge/Reopen/Update/Comments/Commits
  • webhooks.go: webhook CRUD + signature validation + event parsing
  • branches.go: ListBranches, CreateBranch, DeleteBranch
  • diffs.go: GetCRDiff, GetCRFiles, CreateNote/DeleteNote, CreateDiscussion
  • commits.go: GetCommit, ListCommits, CompareCommits, CreateCommitStatus
  • files.go: GetFileContent, CreateFile, UpdateFile, DeleteFile
  • releases.go: ListTags, ListReleases, CreateRelease, GetArchive
  • labels.go: repository label CRUD (LabelManager)
  • issues.go: issue CRUD, comments, and issue labels (IssueManager)
  • reviews.go: PR review list/get/create/dismiss/request-reviewers (ReviewManager)
  • milestones.go: repository milestone CRUD (MilestoneManager)
  • search.go: global repo/issue/user search (SearchManager)
  • gists.go: ListMyGists, token 用户的 gist 列表 (GistManager)
  • starred.go: ListStarred, 认证用户 star 的仓库 (StarredManager)
  • migrations.go: CreateMigration/GetMigration, user/org 归档导出 (MigrationManager)
  • release_assets.go: DownloadReleaseAsset 流式下载附件 (ReleaseAssetManager)
  • types.go: internal GitHub-API types and conversion helpers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Divergences

func Divergences() []provider.Divergence

Divergences returns the registered divergence ledger for the GitHub backend.

func New

New builds a GitHub Provider from the given config. It registers itself with provider.Register so provider.NewProvider(PlatformGitHub, ...) returns an instance of this Provider.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the GitHub implementation of provider.Provider. It embeds the official go-github client and an auxiliary transport.Client used for endpoints not covered by the SDK (e.g. archive downloads).

func (*Provider) AddCRCommentReaction

func (p *Provider) AddCRCommentReaction(ctx context.Context, owner, repo string, commentID int64, emoji string) (*model.Reaction, error)

AddCRCommentReaction implements provider.ReactionManager.

func (*Provider) AddCollaborator

func (p *Provider) AddCollaborator(ctx context.Context, owner, repo, username string, opts provider.AddCollaboratorOptions) error

AddCollaborator implements provider.CollaboratorManager.

func (*Provider) AddDeployKey

func (p *Provider) AddDeployKey(ctx context.Context, owner, repo string, opts provider.AddDeployKeyOptions) (*model.DeployKey, error)

AddDeployKey implements provider.DeploymentKeyManager.

func (*Provider) AddIssueCommentReaction

func (p *Provider) AddIssueCommentReaction(ctx context.Context, owner, repo string, commentID int64, emoji string) (*model.Reaction, error)

AddIssueCommentReaction implements provider.ReactionManager.

func (*Provider) AddIssueLabels

func (p *Provider) AddIssueLabels(ctx context.Context, owner, repo, number string, labels []string) error

AddIssueLabels implements provider.IssueManager.

func (*Provider) AddIssueReaction

func (p *Provider) AddIssueReaction(ctx context.Context, owner, repo, number, emoji string) (*model.Reaction, error)

AddIssueReaction implements provider.ReactionManager.

func (*Provider) Capabilities

func (p *Provider) Capabilities() provider.CapabilitySet

Capabilities implements provider.Provider. GitHub implements the optional LabelManager interface (see labels.go), the IssueManager interface (see issues.go), the ReviewManager interface (see reviews.go), the SearchManager interface (see search.go), and the GitHub-only capabilities GistManager (gists.go), StarredManager (starred.go), MigrationManager (migrations.go), and ReleaseAssetManager (release_assets.go).

func (*Provider) CloseCR

func (p *Provider) CloseCR(ctx context.Context, owner, repo, number string) (*model.ChangeRequest, error)

CloseCR implements provider.ChangeRequestManager.

func (*Provider) CloseIssue

func (p *Provider) CloseIssue(ctx context.Context, owner, repo, number string) (*model.Issue, error)

CloseIssue implements provider.IssueManager.

func (*Provider) CompareCommits

func (p *Provider) CompareCommits(ctx context.Context, owner, repo, base, head string) (*model.CompareResult, error)

CompareCommits implements provider.CommitManager.

commits 走分页拉全(issue #77):GitHub 的 compare 端点单次至多返回 250 条 commits,旧实现传 nil ListOptions 只取一页 ⇒ >250 提交的 compare 静默 截断(仅能靠 TotalCommits 对比察觉)。files 平台侧更严:改动文件列表只在 首页返回且全量上限 300 条、无分页线可走——len==300 时置 CompareResult.FilesTruncated,截断可见(对照:GetCRDiff 的 PR files 线有 分页,走全)。

func (*Provider) CreateBranch

func (p *Provider) CreateBranch(ctx context.Context, owner, repo, branch, ref string) (*model.PlatformBranch, error)

CreateBranch implements provider.BranchManager.

func (*Provider) CreateBranchProtection

func (p *Provider) CreateBranchProtection(ctx context.Context, owner, repo string, opts provider.CreateBranchProtectionOptions) (*model.BranchProtection, error)

CreateBranchProtection implements provider.BranchProtectionManager.

GitHub 的保护端点只有一个 PUT(branches/{branch}/protection),语义是 create-or-replace——直接落线即可创建(issue #73)。旧实现委托 UpdateBranchProtection,而 Update 的「读当前保护再合并」前置在未保护 分支上必然 404 ⇒ create 路径死锁,EnsureBranchProtection 的 EnsureCreated 分支(runtime/ensure.go)在 GitHub 上不可达。 创建按调用方给定的四旋钮直出 wire,不做任何读回。

func (*Provider) CreateCR

CreateCR implements provider.ChangeRequestManager.

func (*Provider) CreateCommitStatus

func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, opts provider.CommitStatusOptions) error

CreateCommitStatus implements provider.CommitStatusManager.

func (*Provider) CreateDeployment

func (p *Provider) CreateDeployment(ctx context.Context, owner, repo, ref, environment string, opts provider.CreateDeploymentOptions) (*model.Deployment, error)

CreateDeployment implements provider.DeploymentManager (GitHub's deployments API is the only wire with a manual create + status state machine; GitLab's deployment records are CI-produced without a manual status wire, so absence is expressed by not declaring).

func (*Provider) CreateDeploymentStatus

func (p *Provider) CreateDeploymentStatus(ctx context.Context, owner, repo string, deploymentID int64, opts provider.DeploymentStatusOptions) error

CreateDeploymentStatus implements provider.DeploymentManager.

func (*Provider) CreateDiscussion

func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo, number string, opts provider.DiscussionOptions) (string, error)

CreateDiscussion implements provider.DiffManager.

func (*Provider) CreateFile

func (p *Provider) CreateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*model.FileResult, error)

CreateFile implements provider.FileManager.

func (*Provider) CreateIssue

func (p *Provider) CreateIssue(ctx context.Context, opts provider.CreateIssueOptions) (*model.Issue, error)

CreateIssue implements provider.IssueManager.

func (*Provider) CreateIssueComment

func (p *Provider) CreateIssueComment(ctx context.Context, owner, repo, number, body string) (*model.IssueComment, error)

CreateIssueComment implements provider.IssueManager.

func (*Provider) CreateLabel

func (p *Provider) CreateLabel(ctx context.Context, owner, repo string, opts provider.CreateLabelOptions) (*model.Label, error)

CreateLabel implements provider.LabelManager.

func (*Provider) CreateMigration

func (p *Provider) CreateMigration(ctx context.Context, org string, opts provider.CreateMigrationOptions) (*model.MigrationInfo, error)

CreateMigration implements provider.MigrationManager. go-github 的 MigrationService 只覆盖组织级端点(orgs/{org}/migrations 且请求体不含 exclude_metadata),而消费方需要 user/org 两条路径共用同一请求体 (lock_repositories + exclude_metadata),因此自行构造请求。 org == "" → POST /user/migrations(用户级),非空 → POST /orgs/{org}/migrations。

func (*Provider) CreateMilestone

func (p *Provider) CreateMilestone(ctx context.Context, owner, repo string, opts provider.CreateMilestoneOptions) (*model.Milestone, error)

CreateMilestone implements provider.MilestoneManager.

func (*Provider) CreateNote

func (p *Provider) CreateNote(ctx context.Context, owner, repo, number, body string) (string, error)

CreateNote implements provider.DiffManager.

func (*Provider) CreateRelease

func (p *Provider) CreateRelease(ctx context.Context, owner, repo string, opts provider.CreateReleaseOptions) (*model.ReleaseInfo, error)

CreateRelease implements provider.ReleaseManager.

func (*Provider) CreateRepo

func (p *Provider) CreateRepo(ctx context.Context, owner string, opts provider.CreateRepoOptions) (*model.PlatformRepo, error)

CreateRepo implements provider.RepoManager.

func (*Provider) CreateRepoFromTemplate

func (p *Provider) CreateRepoFromTemplate(ctx context.Context, templateOwner, templateRepo string, opts provider.CreateRepoFromTemplateOptions) (*model.PlatformRepo, error)

CreateRepoFromTemplate implements provider.TemplateRepoManager.

func (*Provider) CreateReview

func (p *Provider) CreateReview(ctx context.Context, owner, repo, number string, opts provider.CreateReviewOptions) (*model.ReviewResult, error)

CreateReview implements provider.ReviewManager. It moved here from DiffManager; the change request number is now addressed as a string.

func (*Provider) CreateWebhook

CreateWebhook implements provider.WebhookManager.

func (*Provider) DeleteBranch

func (p *Provider) DeleteBranch(ctx context.Context, owner, repo, branch string) error

DeleteBranch implements provider.BranchManager.

func (*Provider) DeleteBranchProtection

func (p *Provider) DeleteBranchProtection(ctx context.Context, owner, repo, branch string) error

DeleteBranchProtection implements provider.BranchProtectionManager.

func (*Provider) DeleteDeployKey

func (p *Provider) DeleteDeployKey(ctx context.Context, owner, repo string, keyID int64) error

DeleteDeployKey implements provider.DeploymentKeyManager.

func (*Provider) DeleteFile

func (p *Provider) DeleteFile(ctx context.Context, owner, repo string, opts provider.FileDeleteOptions) (*model.FileResult, error)

DeleteFile implements provider.FileManager.

func (*Provider) DeleteIssueComment

func (p *Provider) DeleteIssueComment(ctx context.Context, owner, repo, number string, commentID int64) error

DeleteIssueComment implements provider.IssueManager. The delete endpoint addresses the comment directly, so number is unused. Deletion is permanent; the platform only lets the comment's author perform it.

func (*Provider) DeleteLabel

func (p *Provider) DeleteLabel(ctx context.Context, owner, repo, name string) error

DeleteLabel implements provider.LabelManager.

func (*Provider) DeleteMilestone

func (p *Provider) DeleteMilestone(ctx context.Context, owner, repo, number string) error

DeleteMilestone implements provider.MilestoneManager.

func (*Provider) DeleteNote

func (p *Provider) DeleteNote(ctx context.Context, owner, repo, number, noteID string) error

DeleteNote implements provider.DiffManager. The note itself is addressed by its numeric platform ID; the change-request number is only validated, as GitHub's delete-comment endpoint does not take it.

func (*Provider) DeleteRelease

func (p *Provider) DeleteRelease(ctx context.Context, owner, repo, tag string) error

DeleteRelease implements provider.ReleaseManager. The delete endpoint is id-addressed; the tag is resolved through the by-tag endpoint first.

func (*Provider) DeleteRepo

func (p *Provider) DeleteRepo(ctx context.Context, owner, repo string) error

DeleteRepo implements provider.RepoManager.

func (*Provider) DeleteWebhook

func (p *Provider) DeleteWebhook(ctx context.Context, owner, repo string, webhookID int64) error

DeleteWebhook implements provider.WebhookManager.

func (*Provider) DismissReview

func (p *Provider) DismissReview(ctx context.Context, owner, repo, number string, reviewID int64, message string) error

DismissReview implements provider.ReviewManager.

func (*Provider) Divergences

func (p *Provider) Divergences() []provider.Divergence

Divergences implements provider.Provider.

func (*Provider) DownloadReleaseAsset

func (p *Provider) DownloadReleaseAsset(ctx context.Context, owner, repo string, assetID int64, w io.Writer) error

DownloadReleaseAsset implements provider.ReleaseAssetManager.

SDK 内部用 bareDoUntilFound 处理资产端点的 302(GitHub 对 Accept: application/octet-stream 返回重定向而非直接字节流),302 目标 是签名 URL:必须用无鉴权的裸 client 跟随,不能复用 SDK 自己的 http.Client(其 CheckRedirect 被禁用)也不该带上 API Bearer。跟随用 p.followClient —— 同 SkipTLS 策略,GHES 自签场景第二跳不再 x509。 跟随后的响应体经 CheckResponse 校验,非 2xx 直接报错;rc 即字节流, io.Copy 流式写入 w,不整读内存。go-github v93 在本路径恒回非 nil rc (followClient 恒非 nil,空体表现为 200 + 0 字节),因此对复制计数做 显式空体检查,把「无响应体时返回错误」的契约落到实处(issue #164)。

func (*Provider) ForkRepo

func (p *Provider) ForkRepo(ctx context.Context, owner, repo string, opts provider.ForkRepoOptions) (*model.PlatformRepo, error)

ForkRepo implements provider.RepoManager.

func (*Provider) GetArchive

func (p *Provider) GetArchive(ctx context.Context, owner, repo, ref, format string) ([]byte, error)

GetArchive implements provider.ReleaseManager.

下载跳(issue #72 三连修复):

  1. ctx 贯穿 —— NewRequestWithContext,调用方取消/超时必须传导;
  2. 状态码门 —— 非 2xx 的错误页(codeload 限流/抖动时的 HTML)不得 当归档字节返回,经 provider.New 归类(404→ErrNotFound、429→ ErrRateLimited……),调用方分类重试/报错;
  3. 下载走 followClient(无 30s Timeout)——p.client.Client() 挂着 transport.DefaultTimeout,大归档必然被截断;signed URL 本就不该 见 API token(followClient 无 auth 包装,同一 TLS 策略)。

func (*Provider) GetBranchProtection

func (p *Provider) GetBranchProtection(ctx context.Context, owner, repo, branch string) (*model.BranchProtection, error)

GetBranchProtection implements provider.BranchProtectionManager.

func (*Provider) GetCR

func (p *Provider) GetCR(ctx context.Context, owner, repo, number string) (*model.ChangeRequest, error)

GetCR implements provider.ChangeRequestManager.

func (*Provider) GetCRDiff

func (p *Provider) GetCRDiff(ctx context.Context, owner, repo, number string) (*model.MergeDiff, error)

GetCRDiff implements provider.DiffManager.

func (*Provider) GetCRFiles

func (p *Provider) GetCRFiles(ctx context.Context, owner, repo, number string) ([]*model.ChangedFile, error)

GetCRFiles implements provider.DiffManager.

func (*Provider) GetCommit

func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*model.CommitInfo, error)

GetCommit implements provider.CommitManager.

func (*Provider) GetFileContent

func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)

GetFileContent implements provider.FileManager.

DownloadContents 是两跳(contents 元数据 + download_url 取字节),go-github 的契约明示第二跳可能"失败却不报错":非 2xx 时返回 (错误页 body, nil err) (issue #71)——所以除了 err 之外**必须**检查 resp.StatusCode,429/5xx/404 的错误页文本不得当归档内容返回。非 2xx 经 provider.New 归类 (404→ErrNotFound、429→ErrRateLimited……)。

func (*Provider) GetIssue

func (p *Provider) GetIssue(ctx context.Context, owner, repo, number string) (*model.Issue, error)

GetIssue implements provider.IssueManager.

func (*Provider) GetMigration

func (p *Provider) GetMigration(ctx context.Context, org string, id int64) (*model.MigrationInfo, error)

GetMigration implements provider.MigrationManager. org 语义与 CreateMigration 一致:"" 走 GET /user/migrations/{id},非空走 GET /orgs/{org}/migrations/{id}(消费方轮询到 exported/failed 终态)。

func (*Provider) GetMilestone

func (p *Provider) GetMilestone(ctx context.Context, owner, repo, number string) (*model.Milestone, error)

GetMilestone implements provider.MilestoneManager.

func (*Provider) GetReleaseByTag

func (p *Provider) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*model.ReleaseInfo, error)

GetReleaseByTag implements provider.ReleaseManager. GitHub exposes a dedicated tag-addressed endpoint, so no id resolution is needed.

func (*Provider) GetRepo

func (p *Provider) GetRepo(ctx context.Context, owner, repo string) (*model.PlatformRepo, error)

GetRepo implements provider.RepoManager.

func (*Provider) GetReview

func (p *Provider) GetReview(ctx context.Context, owner, repo, number string, reviewID int64) (*model.Review, error)

GetReview implements provider.ReviewManager.

func (*Provider) GetWebhook

func (p *Provider) GetWebhook(ctx context.Context, owner, repo string, webhookID int64) (*model.PlatformWebhook, error)

GetWebhook implements provider.WebhookConfigManager.

func (*Provider) ListBranchProtections

func (p *Provider) ListBranchProtections(ctx context.Context, owner, repo string) ([]*model.BranchProtection, error)

ListBranchProtections implements provider.BranchProtectionManager. GitHub has no list endpoint for branch protections; this returns nil.

func (*Provider) ListBranches

func (p *Provider) ListBranches(ctx context.Context, owner, repo string) ([]*model.PlatformBranch, error)

ListBranches implements provider.BranchManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until the platform returns an empty page) instead of silently truncating at the first page.

func (*Provider) ListCRCommentReactions

func (p *Provider) ListCRCommentReactions(ctx context.Context, owner, repo string, commentID int64) ([]*model.Reaction, error)

ListCRCommentReactions implements provider.ReactionManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListCRComments

func (p *Provider) ListCRComments(ctx context.Context, owner, repo, number string) ([]*model.CRComment, error)

ListCRComments implements provider.ChangeRequestManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListCRCommits

func (p *Provider) ListCRCommits(ctx context.Context, owner, repo, number string) ([]*model.CRCommit, error)

ListCRCommits implements provider.ChangeRequestManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListCRReactions

func (p *Provider) ListCRReactions(ctx context.Context, owner, repo, number string) ([]*model.Reaction, error)

ListCRReactions implements provider.ReactionManager. On GitHub, PRs share the issue reactions API. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListCRs

func (p *Provider) ListCRs(ctx context.Context, opts provider.ListCROptions) ([]*model.ChangeRequest, *int, error)

ListCRs implements provider.ChangeRequestManager.

SourceBranch 口径(issue #78):GitHub 的 head 过滤参数是 「命名空间:分支名」——硬编码 opts.Owner:branch 会把 fork 来源的 PR 静默漏掉(fork PR 的 head 在 fork owner 的命名空间下)。契约按两个形态分流:

  • 带 owner("owner:branch")→ 服务端 head 精确过滤,命名空间锁定;
  • 纯分支名("feature-x")→ 不下发 head 过滤,当前页内按统一 SourceBranch(head.ref,与命名空间无关)客户端后过滤——fork 同名 分支同样命中,与 GitLab 的服务端纯分支名过滤同果(后过滤与 GitLab 服务端过滤的分页语义差异登记 divergence)。

func (*Provider) ListCollaborators

func (p *Provider) ListCollaborators(ctx context.Context, owner, repo string) ([]*model.Collaborator, error)

ListCollaborators implements provider.CollaboratorManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListCommitStatuses

func (p *Provider) ListCommitStatuses(ctx context.Context, owner, repo, sha string) ([]model.CommitStatus, error)

ListCommitStatuses implements provider.CommitStatusManager.

func (*Provider) ListCommits

func (p *Provider) ListCommits(ctx context.Context, owner, repo string, opts provider.ListCommitsOptions) ([]*model.CommitInfo, error)

ListCommits implements provider.CommitManager.

Dual pagination mode: opts.Page > 0 means the caller manages paging explicitly and receives exactly that one page (opts.Page/opts.PerPage honored via NormalizePageOpts); opts.Page == 0 (the default) exhausts pagination via backendutil.AllPages — fetching 100 per page until an empty page — so every matching commit is returned. In full-fetch mode opts.PerPage only sizes the underlying requests and defaults to the platform maximum of 100.

func (*Provider) ListContributors

func (p *Provider) ListContributors(ctx context.Context, owner, repo string) ([]*model.Contributor, error)

ListContributors implements provider.RepoStatsManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListDeployKeys

func (p *Provider) ListDeployKeys(ctx context.Context, owner, repo string) ([]*model.DeployKey, error)

ListDeployKeys implements provider.DeploymentKeyManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListDeployments

func (p *Provider) ListDeployments(ctx context.Context, owner, repo, environment string, page, perPage int) ([]*model.Deployment, int, error)

ListDeployments implements provider.DeploymentManager. The int return is the number of items on the returned page (the IssueManager total convention, per #51/#60): GitHub's deployments API exposes no platform total, and Response.LastPage is a page number (0 on single-page responses), not an item count — using it here fed callers 0 or a page index instead of a count.

func (*Provider) ListFailedJobLogs

func (p *Provider) ListFailedJobLogs(ctx context.Context, owner, repo, sha string) ([]model.JobLog, error)

ListFailedJobLogs implements provider.CILogManager. GitHub 的 CI 线路: runs-by-SHA(ListRepositoryWorkflowRuns 的 head_sha 过滤)→ 每个 run 的 失败 job → presigned job log 拉取尾部。一个 SHA 可有多个 run(每 workflow 文件一条)——按 workflowID 去重只取最新 run(runs 按 created 倒序返回,首见即最新;mapping 分歧已登记)。

func (*Provider) ListForks

func (p *Provider) ListForks(ctx context.Context, owner, repo string) ([]*model.PlatformRepo, error)

ListForks implements provider.RepoStatsManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListIssueCommentReactions

func (p *Provider) ListIssueCommentReactions(ctx context.Context, owner, repo string, commentID int64) ([]*model.Reaction, error)

ListIssueCommentReactions implements provider.ReactionManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListIssueComments

func (p *Provider) ListIssueComments(ctx context.Context, owner, repo, number string) ([]*model.IssueComment, error)

ListIssueComments implements provider.IssueManager.

func (*Provider) ListIssueLabels

func (p *Provider) ListIssueLabels(ctx context.Context, owner, repo string) ([]*model.IssueLabel, error)

ListIssueLabels implements provider.IssueManager: repository-level labels, exhausting pagination (the loop advances until an empty page).

func (*Provider) ListIssueReactions

func (p *Provider) ListIssueReactions(ctx context.Context, owner, repo, number string) ([]*model.Reaction, error)

ListIssueReactions implements provider.ReactionManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListIssues

func (p *Provider) ListIssues(ctx context.Context, opts provider.ListIssuesOptions) ([]*model.Issue, int, error)

ListIssues implements provider.IssueManager.

func (*Provider) ListLabels

func (p *Provider) ListLabels(ctx context.Context, owner, repo string, opts provider.ListLabelsOptions) ([]*model.Label, error)

ListLabels implements provider.LabelManager.

Dual pagination mode: opts.Page > 0 means the caller manages paging explicitly and receives exactly that one page (opts.Page/opts.PerPage honored via NormalizePageOpts); opts.Page == 0 (the default) exhausts pagination via backendutil.AllPages — fetching 100 per page until an empty page — so every label is returned.

func (*Provider) ListMilestones

func (p *Provider) ListMilestones(ctx context.Context, owner, repo string, opts provider.ListMilestonesOptions) ([]model.Milestone, error)

ListMilestones implements provider.MilestoneManager. State contract (issue #61): "open"/"closed" filter; an empty State sends GitHub's explicit "all" — GitHub's own default (open) silently dropped closed milestones, which the unified contract forbids.

Dual pagination mode: opts.Page > 0 means the caller manages paging explicitly and receives exactly that one page (opts.Page/opts.PerPage honored via NormalizePageOpts); opts.Page == 0 (the default) exhausts pagination via backendutil.AllPages — fetching 100 per page until an empty page — so every matching milestone is returned.

func (*Provider) ListMyGists

func (p *Provider) ListMyGists(ctx context.Context, page, perPage int) ([]*model.Gist, error)

ListMyGists implements provider.GistManager. user 传空字符串时 go-github 走 GET /gists——已认证调用返回的是 token 用户自己的 gist 列表(而非全站 公开 gist),正是备份场景要的「token 用户可见列表」。

func (*Provider) ListNotifications

func (p *Provider) ListNotifications(ctx context.Context, opts provider.ListNotificationsOptions) ([]*model.Notification, error)

ListNotifications implements provider.NotificationManager.

Dual pagination mode: opts.Page > 0 means the caller manages paging explicitly and receives exactly that one page (opts.Page/opts.PerPage honored via NormalizePageOpts); opts.Page == 0 (the default) exhausts pagination via backendutil.AllPages — fetching 100 per page until an empty page — so every matching notification is returned.

func (*Provider) ListReleases

func (p *Provider) ListReleases(ctx context.Context, owner, repo string) ([]*model.ReleaseInfo, error)

ListReleases implements provider.ReleaseManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListRepoNotifications

func (p *Provider) ListRepoNotifications(ctx context.Context, owner, repo string, opts provider.ListNotificationsOptions) ([]*model.Notification, error)

ListRepoNotifications implements provider.NotificationManager.

Dual pagination mode, mirroring ListNotifications: opts.Page > 0 returns exactly that one caller-managed page; opts.Page == 0 exhausts pagination via backendutil.AllPages.

func (*Provider) ListRepos

func (p *Provider) ListRepos(ctx context.Context, opts provider.ListRepoOptions) ([]*model.PlatformRepo, error)

ListRepos implements provider.RepoManager. An Owner targets the org endpoint first; GitHub 404s it for personal accounts (not "no repos", which is an empty 200), so a 404 falls back to the user-namespace listing — both namespace kinds are listable without the caller knowing which one the login is (issue #80; registered divergence).

func (*Provider) ListReviews

func (p *Provider) ListReviews(ctx context.Context, owner, repo, number string) ([]model.Review, error)

ListReviews implements provider.ReviewManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListStargazers

func (p *Provider) ListStargazers(ctx context.Context, owner, repo string) ([]*model.CRUser, error)

ListStargazers implements provider.RepoStatsManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListStarred

func (p *Provider) ListStarred(ctx context.Context, page, perPage int) ([]*model.PlatformRepo, error)

ListStarred implements provider.StarredManager.

GET /user/starred 有两种响应形状:Accept 带 star+json 时返回 [{starred_at, repo:{...}}] 包裹形状,否则返回裸 repo 数组。SDK 的 Activity.ListStarred 固定请求包裹形状——服务端一旦返回裸列表(代理改写 Accept、GHES 版本差异),SDK 会把每项解成空 Repository。因此这里自行 构造请求并逐元素探测两种形状,保证兼容;Accept 仍请求 star+json,与 消费方(下游 org_mirror)的线上行为一致。

func (*Provider) ListTags

func (p *Provider) ListTags(ctx context.Context, owner, repo string) ([]*model.TagInfo, error)

ListTags implements provider.ReleaseManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) ListWebhooks

func (p *Provider) ListWebhooks(ctx context.Context, owner, repo string) ([]*model.PlatformWebhook, error)

ListWebhooks implements provider.WebhookManager. The provider interface exposes no paging parameters, so pagination is exhausted via backendutil.AllPages (100 per page until an empty page).

func (*Provider) MarkNotificationRead

func (p *Provider) MarkNotificationRead(ctx context.Context, threadID string) error

MarkNotificationRead implements provider.NotificationManager.

func (*Provider) MarkNotificationsRead

func (p *Provider) MarkNotificationsRead(ctx context.Context, opts provider.MarkNotificationsOptions) error

MarkNotificationsRead implements provider.NotificationManager.

func (*Provider) MarkRepoNotificationsRead

func (p *Provider) MarkRepoNotificationsRead(ctx context.Context, owner, repo string, opts provider.MarkNotificationsOptions) error

MarkRepoNotificationsRead implements provider.NotificationManager.

func (*Provider) MergeCR

func (p *Provider) MergeCR(ctx context.Context, owner, repo, number string, opts provider.MergeCROptions) (*model.ChangeRequest, error)

MergeCR implements provider.ChangeRequestManager.

func (*Provider) ParseWebhookEvent

func (p *Provider) ParseWebhookEvent(r *http.Request, secret string) (*model.NormalizedEvent, error)

func (*Provider) Platform

func (p *Provider) Platform() model.Platform

Platform implements provider.Provider.

func (*Provider) RemoveCRCommentReaction

func (p *Provider) RemoveCRCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) error

RemoveCRCommentReaction implements provider.ReactionManager.

func (*Provider) RemoveCollaborator

func (p *Provider) RemoveCollaborator(ctx context.Context, owner, repo, username string) error

RemoveCollaborator implements provider.CollaboratorManager.

func (*Provider) RemoveIssueCommentReaction

func (p *Provider) RemoveIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) error

RemoveIssueCommentReaction implements provider.ReactionManager.

func (*Provider) RemoveIssueLabel

func (p *Provider) RemoveIssueLabel(ctx context.Context, owner, repo, number, name string) error

RemoveIssueLabel implements provider.IssueManager.

func (*Provider) RemoveIssueLabels

func (p *Provider) RemoveIssueLabels(ctx context.Context, owner, repo, number string, labels []string) error

RemoveIssueLabels implements provider.IssueManager(#163)。GitHub 无 bulk-remove-some 端点(仅单 label DELETE 与全清 DELETE),内部循环保序 收口、首错即停——失败时错误链携带失败单元的 singular op。

func (*Provider) RemoveIssueReaction

func (p *Provider) RemoveIssueReaction(ctx context.Context, owner, repo, number string, reactionID int64) error

RemoveIssueReaction implements provider.ReactionManager.

func (*Provider) ReopenCR

func (p *Provider) ReopenCR(ctx context.Context, owner, repo, number string) (*model.ChangeRequest, error)

ReopenCR implements provider.ChangeRequestManager.

func (*Provider) ReopenIssue

func (p *Provider) ReopenIssue(ctx context.Context, owner, repo, number string) (*model.Issue, error)

ReopenIssue implements provider.IssueManager.

func (*Provider) RequestReviewers

func (p *Provider) RequestReviewers(ctx context.Context, owner, repo, number string, reviewers []string) error

RequestReviewers implements provider.ReviewManager.

func (*Provider) RequestTeamReviewers

func (p *Provider) RequestTeamReviewers(ctx context.Context, owner, repo, number string, teams []string) error

RequestTeamReviewers implements provider.TeamReviewManager (issue #79): GitHub's review-request endpoint carries an independent team_reviewers channel next to the user reviewers; the unified ReviewManager only expresses the user half.

func (*Provider) SearchIssues

SearchIssues implements provider.SearchManager. Repo/State map onto query qualifiers; "is:issue" keeps pull requests out of the results.

func (*Provider) SearchRepos

SearchRepos implements provider.SearchManager.

func (*Provider) SearchUsers

SearchUsers implements provider.SearchManager.

func (*Provider) SyncFork

func (p *Provider) SyncFork(ctx context.Context, owner, repo, branch string) error

SyncFork implements provider.ForkSyncManager via the merge-upstream endpoint: the fork's named branch is fast-forwarded (or merged) from its upstream counterpart; conflicts error and stay on the fork for manual resolution.

func (*Provider) TestConnection

func (p *Provider) TestConnection(ctx context.Context) (*model.TestConnectionResult, error)

TestConnection implements provider.Provider.

func (*Provider) UpdateBranchProtection

func (p *Provider) UpdateBranchProtection(ctx context.Context, owner, repo, branch string, opts provider.UpdateBranchProtectionOptions) (*model.BranchProtection, error)

UpdateBranchProtection implements provider.BranchProtectionManager.

「nil 字段不变」契约(options.go)的逐字段兑现(issue #74):GitHub 的 保护 PUT 是 create-or-replace 全量替换语义,不带 omitempty 的字段 (enforce_admins)与显式 null 的字段(restrictions、required_status_checks) 一律出线,任何未被回填的字段都会被复位。因此先 GET 当前保护,以 current 全字段回填,再把 opts 的非 nil 值覆盖其上:

  • enforce_admins 透传当前值——旧实现硬编码 true,一次「只改评审数」 的更新会把管理员强制静默打开;
  • AllowForcePushes/AllowDeletions 为 nil 时回填当前值——omitempty 使 nil 不出线,全量替换下等价于复位为 false;
  • Restrictions 从 current 回填(Users/Teams/Apps)——不回填则 wire 出 "restrictions": null,push/merge 限制被清空;
  • PR review 三布尔与 status checks 的 strict/contexts 原样保留。

对未保护分支的 Update 返回 GET 的 404(归 ErrNotFound):统一接口的 语义是 create 走 CreateBranchProtection / EnsureBranchProtection, Update 不隐式承担创建。

func (*Provider) UpdateCR

func (p *Provider) UpdateCR(ctx context.Context, owner, repo, number string, opts provider.UpdateCROptions) (*model.ChangeRequest, error)

UpdateCR implements provider.ChangeRequestManager.

func (*Provider) UpdateCRLabels

func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo, number string, labels []string) error

UpdateCRLabels implements provider.ChangeRequestManager.

func (*Provider) UpdateFile

func (p *Provider) UpdateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*model.FileResult, error)

UpdateFile implements provider.FileManager.

func (*Provider) UpdateIssue

func (p *Provider) UpdateIssue(ctx context.Context, owner, repo, number string, opts provider.UpdateIssueOptions) (*model.Issue, error)

UpdateIssue implements provider.IssueManager.

func (*Provider) UpdateIssueComment

func (p *Provider) UpdateIssueComment(ctx context.Context, owner, repo, number string, commentID int64, body string) (*model.IssueComment, error)

UpdateIssueComment implements provider.IssueManager. The edit endpoint addresses the comment directly, so number is unused. The platform only lets the comment's author perform the edit.

func (*Provider) UpdateLabel

func (p *Provider) UpdateLabel(ctx context.Context, owner, repo, name string, opts provider.UpdateLabelOptions) (*model.Label, error)

UpdateLabel implements provider.LabelManager. GitHub addresses labels by name; nil option fields are simply omitted from the PATCH body.

func (*Provider) UpdateMilestone

func (p *Provider) UpdateMilestone(ctx context.Context, owner, repo, number string, opts provider.UpdateMilestoneOptions) (*model.Milestone, error)

UpdateMilestone implements provider.MilestoneManager. Nil fields in opts stay absent from the PATCH body, leaving the milestone unchanged.

func (*Provider) UpdateRelease

func (p *Provider) UpdateRelease(ctx context.Context, owner, repo, tag string, opts provider.UpdateReleaseOptions) (*model.ReleaseInfo, error)

UpdateRelease implements provider.ReleaseManager. The update endpoint is id-addressed, so the tag is resolved through the by-tag endpoint first (exact lookup, no list window). go-github's UpdateReleaseRequest carries pointer fields, and GitHub's PATCH leaves omitted fields unchanged, so nil options pass through untouched.

func (*Provider) UpdateRepo

func (p *Provider) UpdateRepo(ctx context.Context, owner, repo string, opts provider.UpdateRepoOptions) (*model.PlatformRepo, error)

UpdateRepo implements provider.RepoManager.

func (*Provider) UpdateWebhook

func (p *Provider) UpdateWebhook(ctx context.Context, owner, repo string, webhookID int64, opts provider.UpdateWebhookOptions) (*model.PlatformWebhook, error)

UpdateWebhook implements provider.WebhookConfigManager. GitHub's PATCH semantics keep unprovided settings; the config object is only attached when at least one of URL/Secret is being changed so the remaining config keys stay server-side.

func (*Provider) ValidateWebhookSignature

func (p *Provider) ValidateWebhookSignature(r *http.Request, secret string) error

ValidateWebhookSignature implements provider.WebhookManager. It delegates to the platform's registered validator so the signature scheme has exactly one implementation (shared with contracttest); notably an empty secret is rejected rather than silently accepted.

Jump to

Keyboard shortcuts

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