giturl

package
v0.0.0-...-673eb70 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeCloneURL

func NormalizeCloneURL(raw string) string

NormalizeCloneURL 把仓库 URL 调整成可被 git clone 使用的形式。

当前只针对阿里云 Codeup:Codeup 仓库 URL 不带 .git 后缀时 git clone 会失败, 这里在 hostname 命中时自动补 .git。其它平台(GitHub/Gitee/GitLab/Gitea 等) 同时接受带或不带 .git 的 URL,原样返回。

同时兼容 HTTPS(https://codeup.aliyun.com/...)和 SSH(git@codeup.aliyun.com:...)两种形式。

func ParseBranchFromURL

func ParseBranchFromURL(gitURL string) string

ParseBranchFromURL 从 Git 仓库地址中解析分支名,如果未指定则默认返回 main 处理 GitHub 的 tree URL,例如: https://github.com/owner/repo/tree/feat-schema

func RepoFullName

func RepoFullName(raw string) (string, error)

RepoFullName 返回 owner/repo 格式的仓库全名

func ResolveBranch

func ResolveBranch(configuredBranch, repoURL string) string

ResolveBranch 解析分支名,优先使用配置中的 branch,如果为空则从 URL 解析或使用默认 main

Types

type GitURL

type GitURL struct {
	Host  string
	Owner string
	Repo  string
}

GitURL 表示从 URL 解析出来的 Git 仓库信息

func Parse

func Parse(raw string) (*GitURL, error)

Parse 解析 git URL,提取 host/owner/repo

Jump to

Keyboard shortcuts

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