Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(src, dst string, opts ...git.CloneOptions) error
- func Config(key string, opts ...ConfigOptions) (string, error)
- func IsBinary(r io.Reader) (bool, error)
- func LatestFile(repo *Repository, pattern string) (string, string, error)
- func NewCommand(args ...string) *git.Command
- func SetConfig(key string, value string, opts ...ConfigOptions) error
- type CloneOptions
- type CommandOptions
- type Commit
- type Commits
- type ConfigOptions
- type Diff
- type DiffFile
- type DiffFileChange
- type DiffSection
- type Entries
- type File
- type FileStats
- type Hash
- type Reference
- type ReferenceName
- type Repository
- func (r *Repository) CommitsByPage(ref *Reference, page, size int) (Commits, error)
- func (r *Repository) Config(key string, opts ...ConfigOptions) (string, 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) Name() string
- func (r *Repository) Patch(commit *Commit) (string, error)
- func (r *Repository) References() ([]*Reference, error)
- func (r *Repository) SetConfig(key, value string, opts ...ConfigOptions) error
- func (r *Repository) SymbolicRef(name string, ref string) (string, error)
- func (r *Repository) Tree(ref *Reference) (*Tree, error)
- func (r *Repository) TreePath(ref *Reference, path string) (*Tree, error)
- func (r *Repository) UpdateServerInfo() error
- type RunInDirOptions
- 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 )
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 Config ¶ added in v0.5.0
func Config(key string, opts ...ConfigOptions) (string, error)
Config gets a git configuration.
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 LatestFile ¶ added in v0.5.0
func LatestFile(repo *Repository, pattern string) (string, string, error)
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 Commit ¶
type Commit struct { *git.Commit Hash Hash }
Commit is a wrapper around git.Commit with helper methods.
type ConfigOptions ¶ added in v0.5.0
type ConfigOptions struct { File string All bool Add bool CommandOptions }
ConfigOptions are options for Config.
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 Hash Hash // contains filtered or unexported fields }
Reference is a wrapper around git.Reference with helper methods.
func NewReference ¶
NewReference creates a new reference.
func (*Reference) Name ¶
func (r *Reference) Name() ReferenceName
Name returns the reference name i.e. refs/heads/master.
func (*Reference) TargetHash ¶
TargetHash returns the hash of the reference target.
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) 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(key string, opts ...ConfigOptions) (string, error)
Config returns the config value for the given key.
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) Name ¶
func (r *Repository) Name() string
Name returns the name of the repository.
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(key, value string, opts ...ConfigOptions) error
SetConfig sets the config value for the given key.
func (*Repository) SymbolicRef ¶ added in v0.5.0
func (r *Repository) SymbolicRef(name string, ref string) (string, error)
SymbolicRef returns or updates the symbolic reference for the given name. Both name and ref can be empty.
func (*Repository) Tree ¶
func (r *Repository) Tree(ref *Reference) (*Tree, error)
Tree returns the tree for the given reference.
func (*Repository) TreePath ¶
func (r *Repository) TreePath(ref *Reference, path string) (*Tree, error)
TreePath returns the tree for the given path.
func (*Repository) UpdateServerInfo ¶
func (r *Repository) UpdateServerInfo() error
UpdateServerInfo updates the repository server info.
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.