Documentation
¶
Overview ¶
Package github 提供 GitHub 客户端功能(PAT 模式,不含 GitHub App)
Index ¶
- type BranchInfo
- type GetBlobResp
- type GetGitLogsResp
- type GetRepoArchiveResp
- type GetRepoTreeResp
- type GitCommit
- type GitCommitEntry
- type GitUser
- type Github
- func (g *Github) Archive(ctx context.Context, opts *domain.ArchiveOptions) (*domain.GetRepoArchiveResp, error)
- func (g *Github) Blob(ctx context.Context, opts *domain.BlobOptions) (*domain.GetBlobResp, error)
- func (g *Github) Branches(ctx context.Context, opts *domain.BranchesOptions) ([]*domain.BranchInfo, error)
- func (g *Github) CheckPAT(ctx context.Context, token string, repoURL string) (bool, *domain.BindRepository, error)
- func (g *Github) CreateRepoWebhook(ctx context.Context, token, owner, repo, webhookURL, secret string, ...) error
- func (g *Github) CreateWebhook(ctx context.Context, opts *domain.CreateWebhookOptions) error
- func (g *Github) DeleteWebhook(ctx context.Context, opts *domain.WebhookOptions) error
- func (g *Github) DeleteWebhookByURL(ctx context.Context, token, owner, repo, webhookURL string) error
- func (g *Github) GetAuthorizedRepositories(ctx context.Context, token string, installID int64) ([]domain.AuthRepository, error)
- func (g *Github) GetBlob(ctx context.Context, installID int64, token, owner, repo, ref, path string) (*GetBlobResp, error)
- func (g *Github) GetClient(ctx context.Context, token string, installID int64) (*github.Client, error)
- func (g *Github) GetGitLogs(ctx context.Context, installID int64, token, owner, repo, ref, path string, ...) (*GetGitLogsResp, error)
- func (g *Github) GetInstallationToken(ctx context.Context, installID int64) (string, error)
- func (g *Github) GetRepoArchive(ctx context.Context, installID int64, token, owner, repo, ref string) (*GetRepoArchiveResp, error)
- func (g *Github) GetRepoDescription(ctx context.Context, token, owner, repo string) (string, error)
- func (g *Github) GetRepoInfoByPAT(ctx context.Context, token string, repoURL string) (*github.Repository, error)
- func (g *Github) GetRepoTree(ctx context.Context, installID int64, token, owner, repo, ref, path string, ...) (*GetRepoTreeResp, error)
- func (g *Github) GetUserInfoByPAT(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
- func (g *Github) ListBranches(ctx context.Context, installID int64, token, owner, repo string, ...) ([]*BranchInfo, error)
- func (g *Github) ListInstallationRepos(ctx context.Context, installID int64) ([]*github.Repository, error)
- func (g *Github) Logs(ctx context.Context, opts *domain.LogsOptions) (*domain.GetGitLogsResp, error)
- func (g *Github) Repositories(ctx context.Context, opts *domain.RepositoryOptions) ([]domain.AuthRepository, error)
- func (g *Github) Tree(ctx context.Context, opts *domain.TreeOptions) (*domain.GetRepoTreeResp, error)
- func (g *Github) UserInfo(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetBlobResp ¶
type GetBlobResp struct {
Content []byte `json:"content"`
IsBinary bool `json:"is_binary"`
Sha string `json:"sha"`
Size int `json:"size"`
}
GetBlobResp 获取单文件内容响应
type GetGitLogsResp ¶
type GetGitLogsResp struct {
Count int `json:"count"`
Entries []*GitCommitEntry `json:"entries"`
}
GetGitLogsResp 获取提交历史响应
type GetRepoArchiveResp ¶
type GetRepoArchiveResp struct {
ContentLength int64
ContentType string
Reader io.ReadCloser
}
GetRepoArchiveResp 获取仓库压缩包响应
type GetRepoTreeResp ¶
GetRepoTreeResp 获取仓库文件树响应
type GitCommit ¶
type GitCommit struct {
Author *GitUser `json:"author"`
Committer *GitUser `json:"committer"`
Message string `json:"message"`
ParentShas []string `json:"parent_shas"`
Sha string `json:"sha"`
TreeSha string `json:"tree_sha"`
}
GitCommit 提交信息
type GitCommitEntry ¶
type GitCommitEntry struct {
Commit *GitCommit `json:"commit"`
}
GitCommitEntry 包装 commit 对象
type GitUser ¶
type GitUser struct {
Email string `json:"email"`
Name string `json:"name"`
When int64 `json:"when"`
}
GitUser 提交用户信息
type Github ¶
type Github struct {
// contains filtered or unexported fields
}
Github GitHub 客户端(PAT 模式)
func (*Github) Archive ¶
func (g *Github) Archive(ctx context.Context, opts *domain.ArchiveOptions) (*domain.GetRepoArchiveResp, error)
Archive 实现 GitPlatformClient 接口
func (*Github) Blob ¶
func (g *Github) Blob(ctx context.Context, opts *domain.BlobOptions) (*domain.GetBlobResp, error)
Blob 实现 GitPlatformClient 接口
func (*Github) Branches ¶
func (g *Github) Branches(ctx context.Context, opts *domain.BranchesOptions) ([]*domain.BranchInfo, error)
Branches 实现 GitPlatformClient 接口
func (*Github) CheckPAT ¶
func (g *Github) CheckPAT(ctx context.Context, token string, repoURL string) (bool, *domain.BindRepository, error)
CheckPAT 校验 PAT
func (*Github) CreateRepoWebhook ¶
func (g *Github) CreateRepoWebhook(ctx context.Context, token, owner, repo, webhookURL, secret string, events []string) error
CreateRepoWebhook 在仓库上注册 webhook
func (*Github) CreateWebhook ¶
CreateWebhook 实现 GitPlatformClient 接口
func (*Github) DeleteWebhook ¶
DeleteWebhook 实现 GitPlatformClient 接口
func (*Github) DeleteWebhookByURL ¶
func (g *Github) DeleteWebhookByURL(ctx context.Context, token, owner, repo, webhookURL string) error
DeleteWebhookByURL 根据 webhook URL 精确匹配删除 GitHub 仓库上的 webhook
func (*Github) GetAuthorizedRepositories ¶
func (g *Github) GetAuthorizedRepositories(ctx context.Context, token string, installID int64) ([]domain.AuthRepository, error)
GetAuthorizedRepositories 获取可访问的仓库列表 installID > 0 时使用 GitHub App Installation API,否则使用 PAT 的 /user/repos
func (*Github) GetBlob ¶
func (g *Github) GetBlob(ctx context.Context, installID int64, token, owner, repo, ref, path string) (*GetBlobResp, error)
GetBlob 获取单文件内容(PAT 模式)
func (*Github) GetClient ¶
func (g *Github) GetClient(ctx context.Context, token string, installID int64) (*github.Client, error)
GetClient 使用 PAT 或 Installation 创建 GitHub 客户端
func (*Github) GetGitLogs ¶
func (g *Github) GetGitLogs(ctx context.Context, installID int64, token, owner, repo, ref, path string, limit, offset int) (*GetGitLogsResp, error)
GetGitLogs 获取提交历史(PAT 模式)
func (*Github) GetInstallationToken ¶
GetInstallationToken 通过 GitHub App 获取 installation access token
func (*Github) GetRepoArchive ¶
func (g *Github) GetRepoArchive(ctx context.Context, installID int64, token, owner, repo, ref string) (*GetRepoArchiveResp, error)
GetRepoArchive 获取仓库压缩包(PAT 模式)
func (*Github) GetRepoDescription ¶
GetRepoDescription 获取仓库描述(PAT 模式)
func (*Github) GetRepoInfoByPAT ¶
func (g *Github) GetRepoInfoByPAT(ctx context.Context, token string, repoURL string) (*github.Repository, error)
GetRepoInfoByPAT 根据 PAT 获取仓库信息
func (*Github) GetRepoTree ¶
func (g *Github) GetRepoTree(ctx context.Context, installID int64, token, owner, repo, ref, path string, recursive bool) (*GetRepoTreeResp, error)
GetRepoTree 获取仓库文件树(Installation App 模式优先)
func (*Github) GetUserInfoByPAT ¶
func (g *Github) GetUserInfoByPAT(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
GetUserInfoByPAT 根据 PAT 获取用户信息
func (*Github) ListBranches ¶
func (g *Github) ListBranches(ctx context.Context, installID int64, token, owner, repo string, page, perPage int) ([]*BranchInfo, error)
ListBranches 获取仓库分支列表(Installation App 模式优先)
func (*Github) ListInstallationRepos ¶
func (*Github) Logs ¶
func (g *Github) Logs(ctx context.Context, opts *domain.LogsOptions) (*domain.GetGitLogsResp, error)
Logs 实现 GitPlatformClient 接口
func (*Github) Repositories ¶
func (g *Github) Repositories(ctx context.Context, opts *domain.RepositoryOptions) ([]domain.AuthRepository, error)
Repositories 实现 GitPlatformClient 接口
func (*Github) Tree ¶
func (g *Github) Tree(ctx context.Context, opts *domain.TreeOptions) (*domain.GetRepoTreeResp, error)
Tree 实现 GitPlatformClient 接口