git

package
v1.29.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	IgnoreFile        = ".gitignore"
	IgnoreDefaultMode = 0o644
	NoRemoteRC        = 2
)

Variables

View Source
var (
	ErrRemoteNotFound = errors.New("remote not found")
	ErrNotARepository = errors.New("not a git repository")
	ErrNoGit          = errors.New("no git support")
)
View Source
var (
	RemoteRegex     = regexp.MustCompile(`(?P<server>[\w.:]+)[/:](?P<owner>[\w.-]+)/(?P<project>[\w.-]+)\.git$`)
	CommitTemplates = map[string]string{
		"github.com":    "https://github.com/{{ .Owner }}/{{ .Project }}/commit/{{ .Ref }}",
		"gitlab.com":    "https://gitlab.com/{{ .Owner }}/{{ .Project }}/-/commit/{{ .Ref }}",
		"bitbucket.org": "https://bitbucket.org/{{ .Owner }}/{{ .Project }}/commits/{{ .Ref }}",
	}
)

Functions

func CurrentCommit added in v0.106.0

func CurrentCommit(path string) (string, error)

func GetRepositoryPath

func GetRepositoryPath(dir string) (string, error)

GetRepositoryPath Returns the git repository root path if dir is a directory inside a git repository, otherwise returns error

func Ignore

func Ignore(dir string, ignorePaths, excludePaths []string, marker string) (string, error)

Ignore modify/create .ignore file to include a section headed by the marker string and contains the provided ignore and exclude paths. If the section exists, it will append paths to the given section, otherwise writes the section at the end of the file. All file paths must be absolute. dir is a path in the git repository, if a .gitignore file is not found, a new file will be created in the repository root

func IsRepository

func IsRepository(dir string) bool

IsRepository Return true if dir is a path to a directory in a git repository, false otherwise

func MetadataFor added in v0.106.0

func MetadataFor(path, ref string) (map[string]string, error)

func Origin added in v0.106.0

func Origin(path string) (string, error)

Types

type URL added in v0.106.0

type URL struct {
	Server  string
	Owner   string
	Project string
}

func ParseURL added in v0.106.0

func ParseURL(raw string) *URL

Jump to

Keyboard shortcuts

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