Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(src, dst string, opts ...git.CloneOptions) error
- func IsBinary(r io.Reader) (bool, error)
- type Commit
- type Commits
- 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) CountCommits(ref *Reference) (int64, error)
- func (r *Repository) Diff(commit *Commit) (*Diff, error)
- func (r *Repository) HEAD() (*Reference, error)
- func (r *Repository) Name() string
- func (r *Repository) Patch(commit *Commit) (string, error)
- func (r *Repository) References() ([]*Reference, 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 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") // ErrReferenceNotFound is returned when a reference is not found. ErrReferenceNotFound = errors.New("reference not found") // 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 ¶
Types ¶
type Commit ¶
type Commit struct { *git.Commit Hash Hash }
Commit is a wrapper around git.Commit with helper methods.
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) 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) 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) 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 Tree ¶
type Tree struct { *git.Tree Path string Repository *Repository }
Tree is a wrapper around git.Tree with helper methods.