Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(src, dst string, opts ...git.CloneOptions) error
- func IsBinary(r io.Reader) (bool, error)
- func IsZeroHash(h string) bool
- func LatestFile(repo *Repository, ref *Reference, pattern string) (string, string, error)
- func NewCommand(args ...string) *git.Command
- func UpdateServerInfo(ctx context.Context, path string) error
- type Attribute
- type CloneOptions
- type CommandOptions
- type Commit
- type Commits
- type Diff
- type DiffFile
- type DiffFileChange
- type DiffSection
- type Entries
- type File
- type FileStats
- type Reference
- type ReferenceName
- type Repository
- func (r *Repository) CheckAttributes(ref *Reference, path string) ([]Attribute, error)
- func (r *Repository) CommitsByPage(ref *Reference, page, size int) (Commits, error)
- func (r *Repository) Config() (*gcfg.Config, error)
- func (r *Repository) CountCommits(ref *Reference) (int64, error)
- func (r *Repository) Diff(commit *Commit) (*Diff, error)
- func (r *Repository) HEAD() (*Reference, error)
- func (r *Repository) LsTree(ref string) (*Tree, error)
- func (r *Repository) Patch(commit *Commit) (string, error)
- func (r *Repository) References() ([]*Reference, error)
- func (r *Repository) SetConfig(cfg *gcfg.Config) error
- func (r *Repository) StashDiff(index int) (*Diff, error)
- func (r *Repository) SymbolicRef(name string, ref string, opts ...git.SymbolicRefOptions) (string, error)
- func (r *Repository) Tree(ref *Reference) (*Tree, error)
- func (r *Repository) TreePath(ref *Reference, path string) (*Tree, error)
- type RunInDirOptions
- type Tag
- type Tree
- type TreeEntry
Constants ¶
const ( // HEAD represents the name of the HEAD reference. HEAD = "HEAD" // RefsHeads represents the prefix for branch references. RefsHeads = git.RefsHeads // RefsTags represents the prefix for tag references. RefsTags = git.RefsTags )
const ZeroID = git.EmptyID
ZeroID is the zero hash.
Variables ¶
var ( // ErrFileNotFound is returned when a file is not found. ErrFileNotFound = errors.New("file not found") // ErrDirectoryNotFound is returned when a directory is not found. ErrDirectoryNotFound = errors.New("directory not found") // ErrReferenceNotExist is returned when a reference does not exist. ErrReferenceNotExist = git.ErrReferenceNotExist // ErrRevisionNotExist is returned when a revision is not found. ErrRevisionNotExist = git.ErrRevisionNotExist // ErrNotAGitRepository is returned when the given path is not a Git repository. ErrNotAGitRepository = errors.New("not a git repository") )
var ( // DiffMaxFile is the maximum number of files to show in a diff. DiffMaxFiles = 1000 // DiffMaxFileLines is the maximum number of lines to show in a file diff. DiffMaxFileLines = 1000 // DiffMaxLineChars is the maximum number of characters to show in a line diff. DiffMaxLineChars = 1000 )
Functions ¶
func IsBinary ¶
IsBinary detects if data is a binary value based on: http://git.kernel.org/cgit/git/git.git/tree/xdiff-interface.c?id=HEAD#n198
func IsZeroHash ¶ added in v0.7.0
IsZeroHash returns whether the hash is a zero hash.
func LatestFile ¶ added in v0.5.0
LatestFile returns the contents of the first file at the specified path pattern in the repository and its file path.
func NewCommand ¶ added in v0.5.0
func NewCommand(args ...string) *git.Command
NewCommand creates a new git command.
Types ¶
type CloneOptions ¶ added in v0.5.0
type CloneOptions = git.CloneOptions
CloneOptions contain options for cloning a repository.
type CommandOptions ¶ added in v0.5.0
type CommandOptions = git.CommandOptions
CommandOptions contain options for running a git command.
type Diff ¶
type Diff struct { *git.Diff Files []*DiffFile }
Diff is a wrapper around git.Diff with helper methods.
type DiffFile ¶
type DiffFile struct { *git.DiffFile Sections []*DiffSection }
DiffFile is a wrapper to git.DiffFile with helper methods.
func (*DiffFile) Files ¶
func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange)
Files returns the diff files.
type DiffFileChange ¶
type DiffFileChange struct {
// contains filtered or unexported fields
}
DiffFileChange represents a file diff.
func (*DiffFileChange) Hash ¶
func (f *DiffFileChange) Hash() string
Hash returns the diff file hash.
func (*DiffFileChange) Mode ¶
func (f *DiffFileChange) Mode() git.EntryMode
Mode returns the diff file mode.
type DiffSection ¶
type DiffSection struct { *git.DiffSection // contains filtered or unexported fields }
DiffSection is a wrapper to git.DiffSection with helper methods.
type File ¶
type File struct { *git.Blob Entry *TreeEntry }
File is a wrapper around git.Blob with helper methods.
type Reference ¶
type Reference struct { *git.Reference // contains filtered or unexported fields }
Reference is a wrapper around git.Reference with helper methods.
func (*Reference) Name ¶
func (r *Reference) Name() ReferenceName
Name returns the reference name i.e. refs/heads/master.
type ReferenceName ¶
type ReferenceName string
ReferenceName is a Refspec wrapper.
func (ReferenceName) Short ¶
func (r ReferenceName) Short() string
Short returns the short name of the reference i.e. master.
func (ReferenceName) String ¶
func (r ReferenceName) String() string
String returns the reference name i.e. refs/heads/master.
type Repository ¶
Repository is a wrapper around git.Repository with helper methods.
func Init ¶
func Init(path string, bare bool) (*Repository, error)
Init initializes and opens a new git repository.
func Open ¶
func Open(path string) (*Repository, error)
Open opens a git repository at the given path.
func (*Repository) CheckAttributes ¶ added in v0.6.0
func (r *Repository) CheckAttributes(ref *Reference, path string) ([]Attribute, error)
CheckAttributes checks the attributes of the given ref and path.
func (*Repository) CommitsByPage ¶
func (r *Repository) CommitsByPage(ref *Reference, page, size int) (Commits, error)
CommitsByPage returns the commits for a given page and size.
func (*Repository) Config ¶ added in v0.5.0
func (r *Repository) Config() (*gcfg.Config, error)
Config returns the repository Git configuration.
func (*Repository) CountCommits ¶
func (r *Repository) CountCommits(ref *Reference) (int64, error)
CountCommits returns the number of commits in the repository.
func (*Repository) Diff ¶
func (r *Repository) Diff(commit *Commit) (*Diff, error)
Diff returns the diff for the given commit.
func (*Repository) HEAD ¶
func (r *Repository) HEAD() (*Reference, error)
HEAD returns the HEAD reference for a repository.
func (*Repository) LsTree ¶ added in v0.5.0
func (r *Repository) LsTree(ref string) (*Tree, error)
LsTree returns the tree for the given reference.
func (*Repository) Patch ¶
func (r *Repository) Patch(commit *Commit) (string, error)
Patch returns the patch for the given reference.
func (*Repository) References ¶
func (r *Repository) References() ([]*Reference, error)
References returns the references for a repository.
func (*Repository) SetConfig ¶ added in v0.5.0
func (r *Repository) SetConfig(cfg *gcfg.Config) error
SetConfig sets the repository Git configuration.
func (*Repository) StashDiff ¶ added in v0.7.0
func (r *Repository) StashDiff(index int) (*Diff, error)
StashDiff returns the diff of the given stash index.
func (*Repository) SymbolicRef ¶ added in v0.5.0
func (r *Repository) SymbolicRef(name string, ref string, opts ...git.SymbolicRefOptions) (string, error)
SymbolicRef returns or updates the symbolic reference for the given name. Both name and ref can be empty.
type RunInDirOptions ¶ added in v0.5.0
type RunInDirOptions = git.RunInDirOptions
RunInDirOptions are options for RunInDir.
type Tree ¶
type Tree struct { *git.Tree Path string Repository *Repository }
Tree is a wrapper around git.Tree with helper methods.