Documentation ¶
Index ¶
- Variables
- func IsBranchExist(repoPath, branchName string) bool
- func IsTagExist(repoPath, tagName string) bool
- func IsValidHookName(name string) bool
- func NewId(b []byte) (sha1, error)
- func NewIdFromString(s string) (sha1, error)
- func RefEndName(refStr string) string
- type ArchiveType
- type Blob
- type Commit
- func (c *Commit) CommitsBefore() (*list.List, error)
- func (c *Commit) CommitsBeforeUntil(commitId string) (*list.List, error)
- func (c *Commit) CommitsByRange(page int) (*list.List, error)
- func (c *Commit) CommitsCount() (int, error)
- func (c *Commit) CreateArchive(path string, archiveType ArchiveType) error
- func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error)
- func (c *Commit) GetSubModule(entryname string) (*SubModule, error)
- func (c *Commit) GetSubModules() (map[string]*SubModule, error)
- func (c *Commit) IsImageFile(name string) bool
- func (c *Commit) Message() string
- func (c *Commit) Parent(n int) (*Commit, error)
- func (c *Commit) ParentCount() int
- func (c *Commit) ParentId(n int) (id sha1, err error)
- func (c *Commit) SearchCommits(keyword string) (*list.List, error)
- func (c *Commit) Summary() string
- type Entries
- type EntryMode
- type Hook
- type ObjectType
- type PullRequestInfo
- type Repository
- func (repo *Repository) AddRemote(name, path string) error
- func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error)
- func (repo *Repository) CommitsByFileAndRange(branch, file string, page int) (*list.List, error)
- func (repo *Repository) CommitsCount(commitId string) (int, error)
- func (repo *Repository) CommitsCountBetween(startCommitID, endCommitID string) (int, error)
- func (repo *Repository) CreateTag(tagName, idStr string) error
- func (repo *Repository) FileCommitsCount(branch, file string) (int, error)
- func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)
- func (repo *Repository) GetBranches() ([]string, error)
- func (repo *Repository) GetCommit(commitId string) (*Commit, error)
- func (repo *Repository) GetCommitIdOfBranch(branchName string) (string, error)
- func (repo *Repository) GetCommitIdOfTag(tagName string) (string, error)
- func (repo *Repository) GetCommitOfBranch(branchName string) (*Commit, error)
- func (repo *Repository) GetCommitOfTag(tagName string) (*Commit, error)
- func (repo *Repository) GetHook(name string) (*Hook, error)
- func (repo *Repository) GetMergeBase(remoteBranch, headBranch string) (string, error)
- func (repo *Repository) GetPatch(mergeBase, headBranch string) ([]byte, error)
- func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch string) (_ *PullRequestInfo, err error)
- func (repo *Repository) GetTag(tagName string) (*Tag, error)
- func (repo *Repository) GetTags() ([]string, error)
- func (repo *Repository) GetTree(idStr string) (*Tree, error)
- func (repo *Repository) Hooks() ([]*Hook, error)
- func (repo *Repository) IsBranchExist(branchName string) bool
- func (repo *Repository) IsTagExist(tagName string) bool
- func (repo *Repository) Merge(headRepoPath string, baseBranch, headBranch string) error
- func (repo *Repository) RemoveRemote(name string) error
- type Signature
- type SubModule
- type SubModuleFile
- type Tag
- type Tree
- type TreeEntry
- type Version
Constants ¶
This section is empty.
Variables ¶
var CommitsRangeSize = 50
var (
ErrNotExist = errors.New("error not exist")
)
var (
ErrNotValidHook = errors.New("not a valid Git hook")
)
var (
IDNotExist = errors.New("sha1 ID does not exist")
)
Functions ¶
func IsBranchExist ¶
func IsTagExist ¶
func IsValidHookName ¶ added in v0.5.5
IsValidHookName returns true if given name is a valid Git hook.
func NewIdFromString ¶
Create a new sha1 from a Sha1 string of length 40.
func RefEndName ¶
Types ¶
type Commit ¶
type Commit struct { Tree ID sha1 // The id of this commit object Author *Signature Committer *Signature CommitMessage string // contains filtered or unexported fields }
Commit represents a git commit.
func (*Commit) CommitsBeforeUntil ¶
func (*Commit) CommitsCount ¶
func (*Commit) CreateArchive ¶
func (c *Commit) CreateArchive(path string, archiveType ArchiveType) error
func (*Commit) GetCommitOfRelPath ¶
func (*Commit) GetSubModule ¶ added in v0.5.5
func (*Commit) GetSubModules ¶ added in v0.5.5
func (*Commit) IsImageFile ¶ added in v0.6.9
func (*Commit) ParentCount ¶
Return the number of parents of the commit. 0 if this is the root commit, otherwise 1,2,...
type Hook ¶ added in v0.5.5
type Hook struct { IsActive bool // Indicates whether repository has this hook. Content string // Content of hook if it's active. Sample string // Sample content from Git. // contains filtered or unexported fields }
Hook represents a Git hook.
type ObjectType ¶
type ObjectType string
const ( COMMIT ObjectType = "commit" TREE ObjectType = "tree" BLOB ObjectType = "blob" TAG ObjectType = "tag" )
type PullRequestInfo ¶ added in v0.6.9
type Repository ¶
type Repository struct { Path string // contains filtered or unexported fields }
Repository represents a Git repository.
func OpenRepository ¶
func OpenRepository(repoPath string) (*Repository, error)
OpenRepository opens the repository at the given path.
func (*Repository) AddRemote ¶ added in v0.7.0
func (repo *Repository) AddRemote(name, path string) error
AddRemote adds a remote to repository.
func (*Repository) CommitsBetween ¶
used only for single tree, (]
func (*Repository) CommitsByFileAndRange ¶
func (*Repository) CommitsCount ¶
func (repo *Repository) CommitsCount(commitId string) (int, error)
func (*Repository) CommitsCountBetween ¶ added in v0.6.9
func (repo *Repository) CommitsCountBetween(startCommitID, endCommitID string) (int, error)
func (*Repository) CreateTag ¶
func (repo *Repository) CreateTag(tagName, idStr string) error
func (*Repository) FileCommitsCount ¶
func (repo *Repository) FileCommitsCount(branch, file string) (int, error)
func (*Repository) FilesCountBetween ¶ added in v0.6.9
func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)
func (*Repository) GetBranches ¶
func (repo *Repository) GetBranches() ([]string, error)
func (*Repository) GetCommit ¶
func (repo *Repository) GetCommit(commitId string) (*Commit, error)
Find the commit object in the repository.
func (*Repository) GetCommitIdOfBranch ¶
func (repo *Repository) GetCommitIdOfBranch(branchName string) (string, error)
func (*Repository) GetCommitIdOfTag ¶
func (repo *Repository) GetCommitIdOfTag(tagName string) (string, error)
func (*Repository) GetCommitOfBranch ¶
func (repo *Repository) GetCommitOfBranch(branchName string) (*Commit, error)
get branch's last commit or a special commit by id string
func (*Repository) GetCommitOfTag ¶
func (repo *Repository) GetCommitOfTag(tagName string) (*Commit, error)
func (*Repository) GetHook ¶ added in v0.5.5
func (repo *Repository) GetHook(name string) (*Hook, error)
func (*Repository) GetMergeBase ¶ added in v0.7.0
func (repo *Repository) GetMergeBase(remoteBranch, headBranch string) (string, error)
GetMergeBase checks and returns merge base of two branches.
func (*Repository) GetPatch ¶ added in v0.6.9
func (repo *Repository) GetPatch(mergeBase, headBranch string) ([]byte, error)
GetPatch generates and returns patch data between given branches.
func (*Repository) GetPullRequestInfo ¶ added in v0.6.9
func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch string) (_ *PullRequestInfo, err error)
GetPullRequestInfo generates and returns pull request information between base and head branches of repositories.
func (*Repository) GetTag ¶
func (repo *Repository) GetTag(tagName string) (*Tag, error)
GetTag returns a Git tag by given name.
func (*Repository) GetTags ¶
func (repo *Repository) GetTags() ([]string, error)
GetTags returns all tags of given repository.
func (*Repository) GetTree ¶
func (repo *Repository) GetTree(idStr string) (*Tree, error)
Find the tree object in the repository.
func (*Repository) Hooks ¶ added in v0.5.5
func (repo *Repository) Hooks() ([]*Hook, error)
func (*Repository) IsBranchExist ¶
func (repo *Repository) IsBranchExist(branchName string) bool
func (*Repository) IsTagExist ¶
func (repo *Repository) IsTagExist(tagName string) bool
func (*Repository) Merge ¶ added in v0.6.9
func (repo *Repository) Merge(headRepoPath string, baseBranch, headBranch string) error
Merge merges pull request from head repository and branch.
func (*Repository) RemoveRemote ¶ added in v0.7.0
func (repo *Repository) RemoveRemote(name string) error
RemoveRemote removes a remote from repository.
type SubModuleFile ¶ added in v0.5.5
type SubModuleFile struct { *Commit // contains filtered or unexported fields }
SubModuleFile represents a file with submodule type.
func NewSubModuleFile ¶ added in v0.5.5
func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile
func (*SubModuleFile) RefId ¶ added in v0.5.5
func (sf *SubModuleFile) RefId() string
RefId returns reference ID.
func (*SubModuleFile) RefUrl ¶ added in v0.5.5
func (sf *SubModuleFile) RefUrl() string
RefUrl guesses and returns reference URL.
type Tag ¶
type Tag struct { Name string ID sha1 Object sha1 // The id of this commit object Type string Tagger *Signature TagMessage string // contains filtered or unexported fields }
Tag represents a Git tag.
type Tree ¶
type Tree struct { ID sha1 // contains filtered or unexported fields }
A tree is a flat directory listing.
func NewTree ¶
func NewTree(repo *Repository, id sha1) *Tree
func (*Tree) GetTreeEntryByPath ¶
type TreeEntry ¶
type TreeEntry struct { ID sha1 Type ObjectType // contains filtered or unexported fields }
func (*TreeEntry) IsSubModule ¶ added in v0.5.5
type Version ¶
type Version struct {
Major, Minor, Patch int
}
Version represents version of Git.
func GetVersion ¶
GetVersion returns current Git version installed.