{"modulePath":"github.com/chaitin/MonkeyCode/backend","version":"v0.0.0-20261127100309-1b48a8ecf84c","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github 提供 GitHub 客户端功能（PAT 模式，不含 GitHub App）\n\n## Types\n\n```go\ntype BranchInfo struct {\n\tName string `json:\"name\"`\n}\n```\nBranchInfo 分支信息\n\n```go\ntype GetBlobResp struct {\n\tContent  []byte `json:\"content\"`\n\tIsBinary bool   `json:\"is_binary\"`\n\tSha      string `json:\"sha\"`\n\tSize     int    `json:\"size\"`\n}\n```\nGetBlobResp 获取单文件内容响应\n\n```go\ntype GetGitLogsResp struct {\n\tCount   int               `json:\"count\"`\n\tEntries []*GitCommitEntry `json:\"entries\"`\n}\n```\nGetGitLogsResp 获取提交历史响应\n\n```go\ntype GetRepoArchiveResp struct {\n\tContentLength int64\n\tContentType   string\n\tReader        io.ReadCloser\n}\n```\nGetRepoArchiveResp 获取仓库压缩包响应\n\n```go\ntype GetRepoTreeResp struct {\n\tEntries []*TreeEntry `json:\"entries\"`\n\tSHA     string       `json:\"sha\"`\n}\n```\nGetRepoTreeResp 获取仓库文件树响应\n\n```go\ntype GitCommit struct {\n\tAuthor     *GitUser `json:\"author\"`\n\tCommitter  *GitUser `json:\"committer\"`\n\tMessage    string   `json:\"message\"`\n\tParentShas []string `json:\"parent_shas\"`\n\tSha        string   `json:\"sha\"`\n\tTreeSha    string   `json:\"tree_sha\"`\n}\n```\nGitCommit 提交信息\n\n```go\ntype GitCommitEntry struct {\n\tCommit *GitCommit `json:\"commit\"`\n}\n```\nGitCommitEntry 包装 commit 对象\n\n```go\ntype GitUser struct {\n\tEmail string `json:\"email\"`\n\tName  string `json:\"name\"`\n\tWhen  int64  `json:\"when\"`\n}\n```\nGitUser 提交用户信息\n\n```go\ntype Github struct {\n\t// contains filtered or unexported fields\n}\n```\nGithub GitHub 客户端（PAT 模式）\n\n```go\nfunc NewGithub(logger *slog.Logger, cfg *config.Config) *Github\n```\nNewGithub 创建 GitHub 客户端\n\n```go\nfunc (g *Github) Archive(ctx context.Context, opts *domain.ArchiveOptions) (*domain.GetRepoArchiveResp, error)\n```\nArchive 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) Blob(ctx context.Context, opts *domain.BlobOptions) (*domain.GetBlobResp, error)\n```\nBlob 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) Branches(ctx context.Context, opts *domain.BranchesOptions) ([]*domain.BranchInfo, error)\n```\nBranches 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) CheckPAT(ctx context.Context, token string, repoURL string) (bool, *domain.BindRepository, error)\n```\nCheckPAT 校验 PAT\n\n```go\nfunc (g *Github) CreateRepoWebhook(ctx context.Context, token, owner, repo, webhookURL, secret string, events []string) error\n```\nCreateRepoWebhook 在仓库上注册 webhook\n\n```go\nfunc (g *Github) CreateWebhook(ctx context.Context, opts *domain.CreateWebhookOptions) error\n```\nCreateWebhook 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) DeleteWebhook(ctx context.Context, opts *domain.WebhookOptions) error\n```\nDeleteWebhook 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) DeleteWebhookByURL(ctx context.Context, token, owner, repo, webhookURL string) error\n```\nDeleteWebhookByURL 根据 webhook URL 精确匹配删除 GitHub 仓库上的 webhook\n\n```go\nfunc (g *Github) GetAuthorizedRepositories(ctx context.Context, token string, installID int64) ([]domain.AuthRepository, error)\n```\nGetAuthorizedRepositories 获取可访问的仓库列表 installID \u003e 0 时使用 GitHub App Installation API，否则使用 PAT 的 /user/repos\n\n```go\nfunc (g *Github) GetBlob(ctx context.Context, installID int64, token, owner, repo, ref, path string) (*GetBlobResp, error)\n```\nGetBlob 获取单文件内容（PAT 模式）\n\n```go\nfunc (g *Github) GetClient(ctx context.Context, token string, installID int64) (*github.Client, error)\n```\nGetClient 使用 PAT 或 Installation 创建 GitHub 客户端\n\n```go\nfunc (g *Github) GetGitLogs(ctx context.Context, installID int64, token, owner, repo, ref, path string, limit, offset int) (*GetGitLogsResp, error)\n```\nGetGitLogs 获取提交历史（PAT 模式）\n\n```go\nfunc (g *Github) GetInstallationToken(ctx context.Context, installID int64) (string, error)\n```\nGetInstallationToken 通过 GitHub App 获取 installation access token\n\n```go\nfunc (g *Github) GetRepoArchive(ctx context.Context, installID int64, token, owner, repo, ref string) (*GetRepoArchiveResp, error)\n```\nGetRepoArchive 获取仓库压缩包（PAT 模式）\n\n```go\nfunc (g *Github) GetRepoDescription(ctx context.Context, token, owner, repo string) (string, error)\n```\nGetRepoDescription 获取仓库描述（PAT 模式）\n\n```go\nfunc (g *Github) GetRepoInfoByPAT(ctx context.Context, token string, repoURL string) (*github.Repository, error)\n```\nGetRepoInfoByPAT 根据 PAT 获取仓库信息\n\n```go\nfunc (g *Github) GetRepoTree(ctx context.Context, installID int64, token, owner, repo, ref, path string, recursive bool) (*GetRepoTreeResp, error)\n```\nGetRepoTree 获取仓库文件树（Installation App 模式优先）\n\n```go\nfunc (g *Github) GetUserInfoByPAT(ctx context.Context, token string) (*domain.PlatformUserInfo, error)\n```\nGetUserInfoByPAT 根据 PAT 获取用户信息\n\n```go\nfunc (g *Github) ListBranches(ctx context.Context, installID int64, token, owner, repo string, page, perPage int) ([]*BranchInfo, error)\n```\nListBranches 获取仓库分支列表（Installation App 模式优先）\n\n```go\nfunc (g *Github) ListInstallationRepos(ctx context.Context, installID int64) ([]*github.Repository, error)\n```\n\n```go\nfunc (g *Github) Logs(ctx context.Context, opts *domain.LogsOptions) (*domain.GetGitLogsResp, error)\n```\nLogs 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) Repositories(ctx context.Context, opts *domain.RepositoryOptions) (*domain.RepositoryPage, error)\n```\nRepositories 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) Tree(ctx context.Context, opts *domain.TreeOptions) (*domain.GetRepoTreeResp, error)\n```\nTree 实现 GitPlatformClient 接口\n\n```go\nfunc (g *Github) UserInfo(ctx context.Context, token string) (*domain.PlatformUserInfo, error)\n```\nUserInfo 实现 GitPlatformClient 接口\n\n```go\ntype TreeEntry struct {\n\tMode           int    `json:\"mode\"`\n\tName           string `json:\"name\"`\n\tPath           string `json:\"path\"`\n\tSha            string `json:\"sha\"`\n\tSize           int    `json:\"size\"`\n\tLastModifiedAt int64  `json:\"last_modified_at\"`\n}\n```\nTreeEntry 文件树节点\n\n","path":"github.com/chaitin/MonkeyCode/backend/pkg/git/github","name":"github","synopsis":"Package github 提供 GitHub 客户端功能（PAT 模式，不含 GitHub App）","isRedistributable":true}
