gitutil

package
v0.0.0-...-7954b2e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gitutil provides helpers for dealing with git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyInsteadOf

func ApplyInsteadOf(remoteURL string) (url string, err error)

ApplyInsteadOf returns the remote URL with the instead of rules applied.

func DefaultRef

func DefaultRef(url string) (ref plumbing.ReferenceName, err error)

DefaultRef returns a ref pointing at the default HEAD for the repository, since not all repositories will use "main", this will determine it for us.

func DetectGitPath

func DetectGitPath(path string) (string, error)

DetectGitPath returns the repository root of the specified path, if there is one.

func FindInsteadOfMatch

func FindInsteadOfMatch(remoteURL string, urls map[string]*config.URL) *config.URL

FindInsteadOfMatch returns the longest matching URL rule

This is borrowed directly from go-git: https://github.com/go-git/go-git/blob/master/config/url.go#L59

func FindLocalRepoPath

func FindLocalRepoPath() (path string, err error)

FindLocalRepoPath returns the full path to the repository containing the current working directory. This is not really useful for anything except providing a shortcut to that path for tests, and maybe automation tools.

func FindRef

func FindRef(url string, refname string) (ref plumbing.ReferenceName, err error)

FindRef returns a ref from the given refname, or falls back to the default branch for the repository.

func GetRefs

func GetRefs(url string) (refs memory.ReferenceStorage, err error)

GetRefs returns a map of all the available refs

This is borrowed from: https://github.com/go-git/go-git/issues/249#issuecomment-772354474

func LoadGitConfig

func LoadGitConfig() (conf *config.Config, err error)

LoadGitConfig returns the system and global git configs merged together.

This is borrowed directly from go-git: https://github.com/go-git/go-git/blob/master/repository.go#L489

func LocalBranch

func LocalBranch() (ref plumbing.ReferenceName, err error)

LocalBranch returns the current ref for this repository.

func RemoteDefaultBranch

func RemoteDefaultBranch() (ref plumbing.ReferenceName, err error)

RemoteDefaultBranch returns the current ref for this repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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