git

package
v0.0.7-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = errors.New("not found")
	ErrAuthFailed  = errors.New("authentication failed")
	ErrRateLimited = errors.New("rate limited")
)

Functions

func IsGithubHost

func IsGithubHost(host string) bool

func IsGithubRepo

func IsGithubRepo(repoURL string) bool

IsGithubRepo returns true for gh repos

func ParseGitHubRepoURL

func ParseGitHubRepoURL(repoURL string) (owner, repo string, ok bool)

ParseGitHubRepoURL extracts owner and repo from a GitHub URL. Handles HTTPS, SSH, and SCP-style URLs (git@github.com:owner/repo.git). Returns false if the URL is not a GitHub repo.

func RepoHost

func RepoHost(repoURL string) string

RepoHost extracts the host (without port) from any git repository URL — https, ssh://, or scp-style (git@host:org/repo) — falling back to the raw URL when it cannot be parsed.

func ResolveGitRepoRevision

func ResolveGitRepoRevision(ctx context.Context, client GitClient, repoURL string, rev models.GitRepoRevision) (models.GitRepoRevision, error)

ResolveGitRepoRevision ensures the revision has a resolved commit SHA. If Commit is already set, it returns as-is. Otherwise it resolves the branch HEAD or tag SHA using the provided git client.

Types

type GitClient

type GitClient interface {
	CheckAccess(ctx context.Context, repoURL string) (bool, error)
	GetTagSHA(ctx context.Context, repoURL, tag string) (string, error)
	CheckTagExists(ctx context.Context, repoURL, tag string) (bool, error)
	GetBranchHeadSHA(ctx context.Context, repoURL, branch string) (*RepoResult, error)
	GetDefaultBranch(ctx context.Context, repoURL string) (string, error)
	FetchFile(ctx context.Context, repoURL, ref, filePath string) ([]byte, error)
}

func NewGitClientForRepo

func NewGitClientForRepo(repoURL string, creds GitCredentials) (GitClient, error)

NewGitClientForRepo returns a GitClient backed by the GitHub REST API for github.com repos, or the generic go-git client for all other hosts.

type GitCredentials

type GitCredentials struct {
	Token    string
	Username string
	Password string
}

GitCredentials holds optional git authentication material. A zero value selects anonymous access.

type RepoResult

type RepoResult struct {
	HeadSHA string
	Branch  string
}

Jump to

Keyboard shortcuts

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