git

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package git allows working with Git repositories

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBareRoot

func IsBareRoot(path string) (bool, error)

IsRoot returns true if location is the root of a bare git repository

func NameFromRepositoryURL

func NameFromRepositoryURL(url *url.URL) (string, bool)

NameFromRepositoryURL suggests a name for a repository URL based on the last segment of the path, or returns false

func ParseRepository

func ParseRepository(s string) (*url.URL, error)

ParseRepository parses a string that may be in the Git format (git@) or URL format and extracts the appropriate value. Any fragment on the URL is preserved.

Protocols returned: - http, https - file - git

Types

type ChangedRef

type ChangedRef struct {
	Ref string
	Old string
	New string
}

func ParsePostReceive

func ParsePostReceive(r io.Reader) ([]ChangedRef, error)

type GitError

type GitError struct {
	Err    error
	Stdout string
	Stderr string
}

GitError is returned when the underlying Git command returns a non-zero exit code.

func (*GitError) Error

func (e *GitError) Error() string

type Repository

type Repository interface {
	GetRootDir(dir string) (string, error)
	GetOriginURL(dir string) (string, bool, error)
	GetRef(dir string) string
	Clone(dir string, url string) error
	CloneBare(dir string, url string) error
	CloneMirror(dir string, url string) error
	Fetch(dir string) error
	Checkout(dir string, ref string) error
	Archive(dir, ref, format string, w io.Writer) error
	Init(dir string, bare bool) error
	AddRemote(dir string, name, url string) error
	AddLocalConfig(dir, name, value string) error
	ShowFormat(dir, commit, format string) (string, error)
}

Repository represents a git source repository

func NewRepository

func NewRepository() Repository

NewRepository creates a new Repository for the given directory

func NewRepositoryForBinary

func NewRepositoryForBinary(gitBinaryPath string) Repository

NewRepositoryForBinary returns a Repository using the specified git executable.

Jump to

Keyboard shortcuts

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