Documentation
¶
Overview ¶
Package git 提供 Git 仓库拉取功能
Package git 提供 Git 仓库拉取功能 ¶
Package git 提供 Git 仓库拉取功能
Index ¶
- func IsGitHubTreeURL(url string) bool
- func IsTreeURL(url string) bool
- type Fetcher
- func (f *Fetcher) Clone(source, destDir string) error
- func (f *Fetcher) CloneToTemp(source string) (string, error)
- func (f *Fetcher) CloneToTempWithBranch(source, branch string) (string, error)
- func (f *Fetcher) CloneWithBranch(source, destDir, branch string) error
- func (f *Fetcher) NormalizeURL(source string) string
- func (f *Fetcher) RepoKey(source string) (string, error)
- type GitHubTreeURL
- type GitHubTreeURLParser
- type TreeURLInfo
- type TreeURLParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGitHubTreeURL ¶ added in v0.10.0
IsGitHubTreeURL 已废弃,请使用 IsTreeURL Deprecated: Use IsTreeURL instead
Types ¶
type Fetcher ¶
type Fetcher struct {
// DefaultHost 默认的 Git 托管平台
DefaultHost string
}
Fetcher 用于拉取 Git 仓库
func (*Fetcher) CloneToTemp ¶
CloneToTemp 克隆仓库到临时目录,返回临时目录路径
func (*Fetcher) CloneToTempWithBranch ¶ added in v0.10.0
CloneToTempWithBranch 克隆指定分支到临时目录,返回临时目录路径
func (*Fetcher) CloneWithBranch ¶ added in v0.10.0
CloneWithBranch 克隆指定分支的仓库到指定目录 使用 --branch 参数确保克隆正确的分支
func (*Fetcher) NormalizeURL ¶
NormalizeURL 将简短格式的仓库地址转换为完整的 Git URL 支持格式:
- user/repo -> https://github.com/user/repo.git
- https://github.com/user/repo -> https://github.com/user/repo.git
- git@github.com:user/repo.git -> git@github.com:user/repo.git
type GitHubTreeURL ¶ added in v0.10.0
type GitHubTreeURL = TreeURLInfo
GitHubTreeURL 已废弃,请使用 TreeURLInfo Deprecated: Use TreeURLInfo instead
type GitHubTreeURLParser ¶ added in v0.10.0
type GitHubTreeURLParser struct{}
GitHubTreeURLParser 实现 TreeURLParser 接口,用于解析 GitHub Tree URL
func (*GitHubTreeURLParser) Match ¶ added in v0.10.0
func (p *GitHubTreeURLParser) Match(url string) bool
Match 检测 URL 是否为 GitHub tree 格式
func (*GitHubTreeURLParser) Parse ¶ added in v0.10.0
func (p *GitHubTreeURLParser) Parse(url string) (*TreeURLInfo, error)
Parse 解析 GitHub tree URL 输入: https://github.com/AlfonsSkills/skills/tree/main/all-money-back-my-home 输出: &TreeURLInfo{Platform: "github", Owner: "AlfonsSkills", ...}
func (*GitHubTreeURLParser) Platform ¶ added in v0.10.0
func (p *GitHubTreeURLParser) Platform() string
Platform 返回平台名称
type TreeURLInfo ¶ added in v0.10.0
type TreeURLInfo struct {
Platform string // 平台标识 (e.g., "github", "gitlab")
Owner string // 仓库所有者
Repo string // 仓库名
Branch string // 分支名
Path string // 子目录路径,支持多级 (e.g., "category/skill-name")
}
TreeURLInfo 表示仓库子目录 URL 的通用解析结果 用于存储从各平台(GitHub, GitLab 等)解析的 Tree URL 信息
func ParseGitHubTreeURL ¶ added in v0.10.0
func ParseGitHubTreeURL(url string) (*TreeURLInfo, error)
ParseGitHubTreeURL 已废弃,请使用 ParseTreeURL Deprecated: Use ParseTreeURL instead
func ParseTreeURL ¶ added in v0.10.0
func ParseTreeURL(url string) (*TreeURLInfo, error)
ParseTreeURL 工厂方法,自动选择匹配的解析器解析 URL
func (*TreeURLInfo) CloneURL ¶ added in v0.10.0
func (t *TreeURLInfo) CloneURL() string
CloneURL 返回用于 git clone 的标准 URL
func (*TreeURLInfo) RepoSlug ¶ added in v0.10.0
func (t *TreeURLInfo) RepoSlug() string
RepoSlug 返回 owner/repo 格式的仓库标识
type TreeURLParser ¶ added in v0.10.0
type TreeURLParser interface {
// Match 检测 URL 是否匹配该解析器的格式
Match(url string) bool
// Parse 解析 URL 返回 TreeURLInfo
Parse(url string) (*TreeURLInfo, error)
// Platform 返回平台名称标识
Platform() string
}
TreeURLParser 定义仓库 Tree URL 解析器接口 每个平台(GitHub, GitLab 等)实现此接口以支持其特定的 URL 格式