Documentation
¶
Overview ¶
Package gitlab 提供 GitLab 客户端功能,支持多个 GitLab 实例
Index ¶
- func ParseProjectPath(repoURL string) (string, error)
- type BranchInfo
- type GetBlobResp
- type GetGitLogsResp
- type GetRepoArchiveResp
- type GetRepoTreeResp
- type GitCommit
- type GitCommitEntry
- type GitUser
- type Gitlab
- func (g *Gitlab) Archive(ctx context.Context, opts *domain.ArchiveOptions) (*domain.GetRepoArchiveResp, error)
- func (g *Gitlab) BaseURL() string
- func (g *Gitlab) Blob(ctx context.Context, opts *domain.BlobOptions) (*domain.GetBlobResp, error)
- func (g *Gitlab) Branches(ctx context.Context, opts *domain.BranchesOptions) ([]*domain.BranchInfo, error)
- func (g *Gitlab) CheckPAT(ctx context.Context, token string, repoURL string) (bool, *domain.BindRepository, error)
- func (g *Gitlab) CreateProjectWebhook(ctx context.Context, token, repoURL, webhookURL, secretToken string, ...) error
- func (g *Gitlab) CreateWebhook(ctx context.Context, opts *domain.CreateWebhookOptions) error
- func (g *Gitlab) DeleteWebhook(ctx context.Context, opts *domain.WebhookOptions) error
- func (g *Gitlab) DeleteWebhookByURL(ctx context.Context, token, repoURL, webhookURL string, isOAuth bool) error
- func (g *Gitlab) GetAuthorizedRepositories(ctx context.Context, token string) ([]domain.AuthRepository, error)
- func (g *Gitlab) GetBlob(ctx context.Context, token, projectPath, ref, path string, isOAuth bool) (*GetBlobResp, error)
- func (g *Gitlab) GetGitLogs(ctx context.Context, token, projectPath, ref, path string, limit, offset int, ...) (*GetGitLogsResp, error)
- func (g *Gitlab) GetRepoArchive(ctx context.Context, token, projectPath, ref string, isOAuth bool) (*GetRepoArchiveResp, error)
- func (g *Gitlab) GetRepoDescription(ctx context.Context, token, repoURL string, isOAuth bool) (string, error)
- func (g *Gitlab) GetRepoInfoByPAT(ctx context.Context, token string, repoURL string) (*gitlab.Project, error)
- func (g *Gitlab) GetRepoTree(ctx context.Context, token, projectPath, ref, path string, recursive bool, ...) (*GetRepoTreeResp, error)
- func (g *Gitlab) GetUserInfoByPAT(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
- func (g *Gitlab) ListBranches(ctx context.Context, token, projectPath string, isOAuth bool, ...) ([]*BranchInfo, error)
- func (g *Gitlab) Logs(ctx context.Context, opts *domain.LogsOptions) (*domain.GetGitLogsResp, error)
- func (g *Gitlab) Repositories(ctx context.Context, opts *domain.RepositoryOptions) ([]domain.AuthRepository, error)
- func (g *Gitlab) Token() string
- func (g *Gitlab) Tree(ctx context.Context, opts *domain.TreeOptions) (*domain.GetRepoTreeResp, error)
- func (g *Gitlab) UserInfo(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseProjectPath ¶
ParseProjectPath 从仓库 URL 解析出项目路径(path_with_namespace)
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 Gitlab ¶
Gitlab 客户端
func NewGitlabForBaseURL ¶
NewGitlabForBaseURL 根据任意 base_url 创建 GitLab 客户端(无默认 token)
func (*Gitlab) Archive ¶
func (g *Gitlab) Archive(ctx context.Context, opts *domain.ArchiveOptions) (*domain.GetRepoArchiveResp, error)
Archive 实现 GitPlatformClient 接口
func (*Gitlab) Blob ¶
func (g *Gitlab) Blob(ctx context.Context, opts *domain.BlobOptions) (*domain.GetBlobResp, error)
Blob 实现 GitPlatformClient 接口
func (*Gitlab) Branches ¶
func (g *Gitlab) Branches(ctx context.Context, opts *domain.BranchesOptions) ([]*domain.BranchInfo, error)
Branches 实现 GitPlatformClient 接口
func (*Gitlab) CheckPAT ¶
func (g *Gitlab) CheckPAT(ctx context.Context, token string, repoURL string) (bool, *domain.BindRepository, error)
CheckPAT 校验 PAT
func (*Gitlab) CreateProjectWebhook ¶
func (g *Gitlab) CreateProjectWebhook(ctx context.Context, token, repoURL, webhookURL, secretToken string, isOAuth bool) error
CreateProjectWebhook 在 GitLab 项目上注册 webhook
func (*Gitlab) CreateWebhook ¶
CreateWebhook 实现 GitPlatformClient 接口
func (*Gitlab) DeleteWebhook ¶
DeleteWebhook 实现 GitPlatformClient 接口
func (*Gitlab) DeleteWebhookByURL ¶
func (g *Gitlab) DeleteWebhookByURL(ctx context.Context, token, repoURL, webhookURL string, isOAuth bool) error
DeleteWebhookByURL 根据 webhook URL 精确匹配删除 GitLab 项目上的 webhook
func (*Gitlab) GetAuthorizedRepositories ¶
func (g *Gitlab) GetAuthorizedRepositories(ctx context.Context, token string) ([]domain.AuthRepository, error)
GetAuthorizedRepositories 获取 token 可访问的仓库列表
func (*Gitlab) GetBlob ¶
func (g *Gitlab) GetBlob(ctx context.Context, token, projectPath, ref, path string, isOAuth bool) (*GetBlobResp, error)
GetBlob 获取单文件内容
func (*Gitlab) GetGitLogs ¶
func (g *Gitlab) GetGitLogs(ctx context.Context, token, projectPath, ref, path string, limit, offset int, isOAuth bool) (*GetGitLogsResp, error)
GetGitLogs 获取提交历史
func (*Gitlab) GetRepoArchive ¶
func (g *Gitlab) GetRepoArchive(ctx context.Context, token, projectPath, ref string, isOAuth bool) (*GetRepoArchiveResp, error)
GetRepoArchive 获取仓库压缩包
func (*Gitlab) GetRepoDescription ¶
func (g *Gitlab) GetRepoDescription(ctx context.Context, token, repoURL string, isOAuth bool) (string, error)
GetRepoDescription 获取仓库描述
func (*Gitlab) GetRepoInfoByPAT ¶
func (g *Gitlab) GetRepoInfoByPAT(ctx context.Context, token string, repoURL string) (*gitlab.Project, error)
GetRepoInfoByPAT 根据 PAT 获取仓库信息
func (*Gitlab) GetRepoTree ¶
func (g *Gitlab) GetRepoTree(ctx context.Context, token, projectPath, ref, path string, recursive bool, isOAuth bool) (*GetRepoTreeResp, error)
GetRepoTree 获取仓库文件树
func (*Gitlab) GetUserInfoByPAT ¶
func (g *Gitlab) GetUserInfoByPAT(ctx context.Context, token string) (*domain.PlatformUserInfo, error)
GetUserInfoByPAT 根据 PAT 获取用户信息
func (*Gitlab) ListBranches ¶
func (g *Gitlab) ListBranches(ctx context.Context, token, projectPath string, isOAuth bool, page, perPage int) ([]*BranchInfo, error)
ListBranches 获取仓库分支列表
func (*Gitlab) Logs ¶
func (g *Gitlab) Logs(ctx context.Context, opts *domain.LogsOptions) (*domain.GetGitLogsResp, error)
Logs 实现 GitPlatformClient 接口
func (*Gitlab) Repositories ¶
func (g *Gitlab) Repositories(ctx context.Context, opts *domain.RepositoryOptions) ([]domain.AuthRepository, error)
Repositories 实现 GitPlatformClient 接口
func (*Gitlab) Tree ¶
func (g *Gitlab) Tree(ctx context.Context, opts *domain.TreeOptions) (*domain.GetRepoTreeResp, error)
Tree 实现 GitPlatformClient 接口