Documentation ¶
Index ¶
- Constants
- Variables
- func AddChanges(repoPath string, all bool, files ...string) error
- func BinVersion() (string, error)
- func Checkout(repoPath string, opts CheckoutOptions) error
- func Clone(from, to string, opts CloneRepoOptions) (err error)
- func CommitChanges(repoPath string, opts CommitChangesOptions) error
- func CommitsCount(repoPath, revision string) (int64, error)
- func Fsck(repoPath string, timeout time.Duration, args ...string) error
- func GetFullCommitID(repoPath, shortID string) (string, error)
- func GetLatestCommitTime(repoPath string) (time.Time, error)
- func InitRepository(repoPath string, bare bool) error
- func IsBranchExist(repoPath, name string) bool
- func IsErrExecTimeout(err error) bool
- func IsErrNotExist(err error) bool
- func IsErrUnsupportedVersion(err error) bool
- func IsReferenceExist(repoPath, name string) bool
- func IsRepoURLAccessible(url string) bool
- func IsTagExist(repoPath, name string) bool
- func IsValidHookName(name string) bool
- func MoveFile(repoPath, oldTreeName, newTreeName string) error
- func Pull(repoPath string, opts PullRemoteOptions) error
- func Push(repoPath string, opts PushOptions) error
- func RefEndName(refStr string) string
- func ResetHEAD(repoPath string, hard bool, revision string) error
- func SetUpdateHook(repoPath, content string) (err error)
- func Version() string
- type ArchiveType
- type Blob
- type Branch
- type CheckoutOptions
- type CloneRepoOptions
- type Command
- func (c *Command) AddArguments(args ...string) *Command
- func (c *Command) Run() (string, error)
- func (c *Command) RunInDir(dir string) (string, error)
- func (c *Command) RunInDirBytes(dir string) ([]byte, error)
- func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error
- func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error)
- func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error
- func (c *Command) RunTimeout(timeout time.Duration) (string, error)
- func (c *Command) String() string
- type Commit
- func (c *Commit) CommitsBefore() (*list.List, error)
- func (c *Commit) CommitsBeforeLimit(num int) (*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() (int64, error)
- func (c *Commit) CreateArchive(target string, archiveType ArchiveType) error
- func (c *Commit) GetCommitByPath(relpath string) (*Commit, error)
- func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error)
- func (c *Commit) GetSubModule(entryname string) (*SubModule, error)
- func (c *Commit) GetSubModules() (*ObjectCache, 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) (SHA1, error)
- func (c *Commit) SearchCommits(keyword string, all bool) (*list.List, error)
- func (c *Commit) Summary() string
- type CommitChangesOptions
- type CommitFileStatus
- type CommitGPGSignature
- type CountObject
- type DeleteBranchOptions
- type Entries
- type EntryMode
- type ErrBadLink
- type ErrExecTimeout
- type ErrNotExist
- type ErrUnsupportedVersion
- type Hook
- type LastCommitCache
- type ObjectCache
- type ObjectType
- type PullRemoteOptions
- type PullRequestInfo
- type PushOptions
- type Reference
- type Repository
- func (repo *Repository) AddRemote(name, url string, fetch bool) error
- func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error)
- func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error)
- func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error)
- func (repo *Repository) CommitsCountBetween(start, end string) (int64, error)
- func (repo *Repository) CreateBranch(branch, newBranch string) error
- func (repo *Repository) CreateTag(name, revision string) error
- func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) error
- func (repo *Repository) FileBlame(revision, path, file string) ([]byte, error)
- func (repo *Repository) FileCommitsCount(revision, file string) (int64, error)
- func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)
- func (repo *Repository) GetBlob(idStr string) (*Blob, error)
- func (repo *Repository) GetBranchCommit(name string) (*Commit, error)
- func (repo *Repository) GetBranchCommitID(name string) (string, error)
- func (repo *Repository) GetBranches() ([]string, error)
- func (repo *Repository) GetCommit(commitID string) (*Commit, error)
- func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error)
- func (repo *Repository) GetFormatPatch(base, head string) (io.Reader, error)
- func (repo *Repository) GetHEADBranch() (*Branch, error)
- func (repo *Repository) GetHook(name string) (*Hook, error)
- func (repo *Repository) GetMergeBase(base, head string) (string, error)
- func (repo *Repository) GetPatch(base, head string) ([]byte, error)
- func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch string) (_ *PullRequestInfo, err error)
- func (repo *Repository) GetRefCommitID(name string) (string, error)
- func (repo *Repository) GetRefs() ([]*Reference, error)
- func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error)
- func (repo *Repository) GetTag(name string) (*Tag, error)
- func (repo *Repository) GetTagCommit(name string) (*Commit, error)
- func (repo *Repository) GetTagCommitID(name string) (string, error)
- func (repo *Repository) GetTagInfos() ([]*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(name string) bool
- func (repo *Repository) IsTagExist(name string) bool
- func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error)
- func (repo *Repository) RemoveRemote(name string) error
- func (repo *Repository) SetDefaultBranch(name string) error
- type SHA1
- type Signature
- type SubModule
- type SubModuleFile
- type Tag
- type Tree
- type TreeEntry
- func (te *TreeEntry) Blob() *Blob
- func (te *TreeEntry) FollowLink() (*TreeEntry, error)
- func (te *TreeEntry) GetSubJumpablePathName() string
- func (te *TreeEntry) IsDir() bool
- func (te *TreeEntry) IsLink() bool
- func (te *TreeEntry) IsSubModule() bool
- func (te *TreeEntry) Mode() EntryMode
- func (te *TreeEntry) Name() string
- func (te *TreeEntry) Size() int64
Constants ¶
const BranchPrefix = "refs/heads/"
BranchPrefix base dir of the branch information file store on git
const EmptySHA = "0000000000000000000000000000000000000000"
EmptySHA defines empty git SHA
const (
// GitTimeLayout is the (default) time layout used by git.
GitTimeLayout = "Mon Jan _2 15:04:05 2006 -0700"
)
const (
// HookPathUpdate hook update path
HookPathUpdate = "hooks/update"
)
const TagPrefix = "refs/tags/"
TagPrefix tags prefix path on the repository
Variables ¶
var ( // GlobalCommandArgs global command args for external package setting GlobalCommandArgs []string // DefaultCommandExecutionTimeout default command execution timeout duration DefaultCommandExecutionTimeout = 60 * time.Second )
var ( // Debug enables verbose logging on everything. // This should be false in case Gogs starts in SSH mode. Debug = false // Prefix the log prefix Prefix = "[git-module] " // GitVersionRequired is the minimum Git version required GitVersionRequired = "1.7.2" )
var CommitsRangeSize = 50
CommitsRangeSize the default commits range size
var ( // ErrNotValidHook error when a git hook is not valid ErrNotValidHook = errors.New("not a valid Git hook") )
Functions ¶
func AddChanges ¶
AddChanges marks local changes to be ready for commit.
func BinVersion ¶
BinVersion returns current Git version from shell.
func Checkout ¶
func Checkout(repoPath string, opts CheckoutOptions) error
Checkout checkouts a branch
func Clone ¶
func Clone(from, to string, opts CloneRepoOptions) (err error)
Clone clones original repository to target path.
func CommitChanges ¶
func CommitChanges(repoPath string, opts CommitChangesOptions) error
CommitChanges commits local changes with given committer, author and message. If author is nil, it will be the same as committer.
func CommitsCount ¶
CommitsCount returns number of total commits of until given revision.
func GetFullCommitID ¶
GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.
func GetLatestCommitTime ¶
GetLatestCommitTime returns time for latest commit in repository (across all branches)
func InitRepository ¶
InitRepository initializes a new Git repository.
func IsBranchExist ¶
IsBranchExist returns true if given branch exists in the repository.
func IsErrExecTimeout ¶
IsErrExecTimeout if some error is ErrExecTimeout
func IsErrUnsupportedVersion ¶
IsErrUnsupportedVersion if some error is ErrUnsupportedVersion
func IsReferenceExist ¶
IsReferenceExist returns true if given reference exists in the repository.
func IsRepoURLAccessible ¶
IsRepoURLAccessible checks if given repository URL is accessible.
func IsTagExist ¶
IsTagExist returns true if given tag exists in the repository.
func IsValidHookName ¶
IsValidHookName returns true if given name is a valid Git hook.
func Pull ¶
func Pull(repoPath string, opts PullRemoteOptions) error
Pull pulls changes from remotes.
func Push ¶
func Push(repoPath string, opts PushOptions) error
Push pushs local commits to given remote branch.
func RefEndName ¶
RefEndName return the end name of a ref name
func SetUpdateHook ¶
SetUpdateHook writes given content to update hook of the reposiotry.
Types ¶
type ArchiveType ¶
type ArchiveType int
ArchiveType archive types
const ( // ZIP zip archive type ZIP ArchiveType = iota + 1 // TARGZ tar gz archive type TARGZ )
type Blob ¶
type Blob struct { *TreeEntry // contains filtered or unexported fields }
Blob represents a Git object.
func (*Blob) Data ¶
Data gets content of blob all at once and wrap it as io.Reader. This can be very slow and memory consuming for huge content.
type CheckoutOptions ¶
CheckoutOptions options when heck out some branch
type CloneRepoOptions ¶
type CloneRepoOptions struct { Timeout time.Duration Mirror bool Bare bool Quiet bool Branch string }
CloneRepoOptions options when clone a repository
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a command with its subcommands or arguments.
func NewCommand ¶
NewCommand creates and returns a new Git Command based on given command and arguments.
func (*Command) AddArguments ¶
AddArguments adds new argument(s) to the command.
func (*Command) Run ¶
Run executes the command in defualt working directory and returns stdout in string and error (combined with stderr).
func (*Command) RunInDir ¶
RunInDir executes the command in given directory and returns stdout in string and error (combined with stderr).
func (*Command) RunInDirBytes ¶
RunInDirBytes executes the command in given directory and returns stdout in []byte and error (combined with stderr).
func (*Command) RunInDirPipeline ¶
RunInDirPipeline executes the command in given directory, it pipes stdout and stderr to given io.Writer.
func (*Command) RunInDirTimeout ¶
RunInDirTimeout executes the command in given directory with given timeout, and returns stdout in []byte and error (combined with stderr).
func (*Command) RunInDirTimeoutPipeline ¶
func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error
RunInDirTimeoutPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer.
func (*Command) RunTimeout ¶
RunTimeout executes the command in defualt working directory with given timeout, and returns stdout in string and error (combined with stderr).
type Commit ¶
type Commit struct { Branch string // Branch this commit belongs to Tree ID SHA1 // The ID of this commit object Author *Signature Committer *Signature CommitMessage string Signature *CommitGPGSignature // contains filtered or unexported fields }
Commit represents a git commit.
func (*Commit) CommitsBefore ¶
CommitsBefore returns all the commits before current revision
func (*Commit) CommitsBeforeLimit ¶
CommitsBeforeLimit returns num commits before current revision
func (*Commit) CommitsBeforeUntil ¶
CommitsBeforeUntil returns the commits between commitID to current revision
func (*Commit) CommitsByRange ¶
CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize
func (*Commit) CommitsCount ¶
CommitsCount returns number of total commits of until current revision.
func (*Commit) CreateArchive ¶
func (c *Commit) CreateArchive(target string, archiveType ArchiveType) error
CreateArchive create archive content to the target path
func (*Commit) GetCommitByPath ¶
GetCommitByPath return the commit of relative path object.
func (*Commit) GetFilesChangedSinceCommit ¶
GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision
func (*Commit) GetSubModule ¶
GetSubModule get the sub module according entryname
func (*Commit) GetSubModules ¶
func (c *Commit) GetSubModules() (*ObjectCache, error)
GetSubModules get all the sub modules of current revision git tree
func (*Commit) IsImageFile ¶
IsImageFile is a file image type
func (*Commit) Message ¶
Message returns the commit message. Same as retrieving CommitMessage directly.
func (*Commit) ParentCount ¶
ParentCount returns number of parents of the commit. 0 if this is the root commit, otherwise 1,2, etc.
func (*Commit) ParentID ¶
ParentID returns oid of n-th parent (0-based index). It returns nil if no such parent exists.
func (*Commit) SearchCommits ¶
SearchCommits returns the commits match the keyword before current revision
type CommitChangesOptions ¶
CommitChangesOptions the options when a commit created
type CommitFileStatus ¶
CommitFileStatus represents status of files in a commit.
func GetCommitFileStatus ¶
func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error)
GetCommitFileStatus returns file status of commit in given repository.
func NewCommitFileStatus ¶
func NewCommitFileStatus() *CommitFileStatus
NewCommitFileStatus creates a CommitFileStatus
type CommitGPGSignature ¶
type CommitGPGSignature struct { Signature string Payload string //TODO check if can be reconstruct from the rest of commit information to not have duplicate data }
CommitGPGSignature represents a git commit signature part.
type CountObject ¶
type CountObject struct { Count int64 Size int64 InPack int64 Packs int64 SizePack int64 PrunePack int64 Garbage int64 SizeGarbage int64 }
CountObject represents repository count objects report
func GetRepoSize ¶
func GetRepoSize(repoPath string) (*CountObject, error)
GetRepoSize returns disk consumption for repo in path
type DeleteBranchOptions ¶
type DeleteBranchOptions struct {
Force bool
}
DeleteBranchOptions Option(s) for delete branch
type Entries ¶
type Entries []*TreeEntry
Entries a list of entry
func (Entries) CustomSort ¶
CustomSort customizable string comparing sort entry list
func (Entries) GetCommitsInfo ¶
func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, error)
GetCommitsInfo gets information of all commits that are corresponding to these entries
type EntryMode ¶
type EntryMode int
EntryMode the type of the object in the git tree
const ( // EntryModeBlob EntryModeBlob EntryMode = 0x0100644 // EntryModeExec EntryModeExec EntryMode = 0x0100755 // EntryModeSymlink EntryModeSymlink EntryMode = 0x0120000 // EntryModeCommit EntryModeCommit EntryMode = 0x0160000 // EntryModeTree EntryModeTree EntryMode = 0x0040000 )
There are only a few file modes in Git. They look like unix file modes, but they can only be one of these.
type ErrBadLink ¶
ErrBadLink entry.FollowLink error
func (ErrBadLink) Error ¶
func (err ErrBadLink) Error() string
type ErrExecTimeout ¶
ErrExecTimeout error when exec timed out
func (ErrExecTimeout) Error ¶
func (err ErrExecTimeout) Error() string
type ErrNotExist ¶
ErrNotExist commit not exist error
func (ErrNotExist) Error ¶
func (err ErrNotExist) Error() string
type ErrUnsupportedVersion ¶
type ErrUnsupportedVersion struct {
Required string
}
ErrUnsupportedVersion error when required git version not matched
func (ErrUnsupportedVersion) Error ¶
func (err ErrUnsupportedVersion) Error() string
type Hook ¶
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 LastCommitCache ¶
type LastCommitCache interface { Get(repoPath, ref, entryPath string) (*Commit, error) Put(repoPath, ref, entryPath string, commit *Commit) error }
LastCommitCache cache
type ObjectCache ¶
type ObjectCache struct {
// contains filtered or unexported fields
}
ObjectCache provides thread-safe cache opeations.
func (*ObjectCache) Get ¶
func (oc *ObjectCache) Get(id string) (interface{}, bool)
Get get cached obj by id
func (*ObjectCache) Set ¶
func (oc *ObjectCache) Set(id string, obj interface{})
Set add obj to cache
type ObjectType ¶
type ObjectType string
ObjectType git object type
const ( // ObjectCommit commit object type ObjectCommit ObjectType = "commit" // ObjectTree tree object type ObjectTree ObjectType = "tree" // ObjectBlob blob object type ObjectBlob ObjectType = "blob" // ObjectTag tag object type ObjectTag ObjectType = "tag" )
type PullRemoteOptions ¶
type PullRemoteOptions struct { Timeout time.Duration All bool Rebase bool Remote string Branch string }
PullRemoteOptions options when pull from remote
type PullRequestInfo ¶
PullRequestInfo represents needed information for a pull request.
type PushOptions ¶
PushOptions options when push to remote
type Reference ¶
type Reference struct { Name string Object SHA1 // The id of this commit object Type string // contains filtered or unexported fields }
Reference represents a Git ref.
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 ¶
func (repo *Repository) AddRemote(name, url string, fetch bool) error
AddRemote adds a new remote to repository.
func (*Repository) CommitsBetween ¶
CommitsBetween returns a list that contains commits between [last, before).
func (*Repository) CommitsBetweenIDs ¶
func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error)
CommitsBetweenIDs return commits between twoe commits
func (*Repository) CommitsByFileAndRange ¶
CommitsByFileAndRange return the commits accroding revison file and the page
func (*Repository) CommitsCountBetween ¶
func (repo *Repository) CommitsCountBetween(start, end string) (int64, error)
CommitsCountBetween return numbers of commits between two commits
func (*Repository) CreateBranch ¶
func (repo *Repository) CreateBranch(branch, newBranch string) error
CreateBranch create a new branch
func (*Repository) CreateTag ¶
func (repo *Repository) CreateTag(name, revision string) error
CreateTag create one tag in the repository
func (*Repository) DeleteBranch ¶
func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) error
DeleteBranch delete a branch by name on repository.
func (*Repository) FileBlame ¶
func (repo *Repository) FileBlame(revision, path, file string) ([]byte, error)
FileBlame return the Blame object of file
func (*Repository) FileCommitsCount ¶
func (repo *Repository) FileCommitsCount(revision, file string) (int64, error)
FileCommitsCount return the number of files at a revison
func (*Repository) FilesCountBetween ¶
func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)
FilesCountBetween return the number of files changed between two commits
func (*Repository) GetBlob ¶
func (repo *Repository) GetBlob(idStr string) (*Blob, error)
GetBlob finds the blob object in the repository.
func (*Repository) GetBranchCommit ¶
func (repo *Repository) GetBranchCommit(name string) (*Commit, error)
GetBranchCommit returns the last commit of given branch.
func (*Repository) GetBranchCommitID ¶
func (repo *Repository) GetBranchCommitID(name string) (string, error)
GetBranchCommitID returns last commit ID string of given branch.
func (*Repository) GetBranches ¶
func (repo *Repository) GetBranches() ([]string, error)
GetBranches returns all branches of the repository.
func (*Repository) GetCommit ¶
func (repo *Repository) GetCommit(commitID string) (*Commit, error)
GetCommit returns commit object of by ID string.
func (*Repository) GetCommitByPath ¶
func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error)
GetCommitByPath returns the last commit of relative path.
func (*Repository) GetFormatPatch ¶
func (repo *Repository) GetFormatPatch(base, head string) (io.Reader, error)
GetFormatPatch generates and returns format-patch data between given revisions.
func (*Repository) GetHEADBranch ¶
func (repo *Repository) GetHEADBranch() (*Branch, error)
GetHEADBranch returns corresponding branch of HEAD.
func (*Repository) GetHook ¶
func (repo *Repository) GetHook(name string) (*Hook, error)
GetHook get one hook accroding the name on a repository
func (*Repository) GetMergeBase ¶
func (repo *Repository) GetMergeBase(base, head string) (string, error)
GetMergeBase checks and returns merge base of two branches.
func (*Repository) GetPatch ¶
func (repo *Repository) GetPatch(base, head string) ([]byte, error)
GetPatch generates and returns patch data between given revisions.
func (*Repository) GetPullRequestInfo ¶
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) GetRefCommitID ¶
func (repo *Repository) GetRefCommitID(name string) (string, error)
GetRefCommitID returns the last commit ID string of given reference (branch or tag).
func (*Repository) GetRefs ¶
func (repo *Repository) GetRefs() ([]*Reference, error)
GetRefs returns all references of the repository.
func (*Repository) GetRefsFiltered ¶
func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error)
GetRefsFiltered returns all references of the repository that matches patterm exactly or starting with.
func (*Repository) GetTag ¶
func (repo *Repository) GetTag(name string) (*Tag, error)
GetTag returns a Git tag by given name.
func (*Repository) GetTagCommit ¶
func (repo *Repository) GetTagCommit(name string) (*Commit, error)
GetTagCommit get the commit of the specific tag via name
func (*Repository) GetTagCommitID ¶
func (repo *Repository) GetTagCommitID(name string) (string, error)
GetTagCommitID returns last commit ID string of given tag.
func (*Repository) GetTagInfos ¶
func (repo *Repository) GetTagInfos() ([]*Tag, error)
GetTagInfos returns all tag infos of the repository.
func (*Repository) GetTags ¶
func (repo *Repository) GetTags() ([]string, error)
GetTags returns all tags of the repository.
func (*Repository) GetTree ¶
func (repo *Repository) GetTree(idStr string) (*Tree, error)
GetTree find the tree object in the repository.
func (*Repository) Hooks ¶
func (repo *Repository) Hooks() ([]*Hook, error)
Hooks get all the hooks on the repository
func (*Repository) IsBranchExist ¶
func (repo *Repository) IsBranchExist(name string) bool
IsBranchExist returns true if given branch exists in current repository.
func (*Repository) IsTagExist ¶
func (repo *Repository) IsTagExist(name string) bool
IsTagExist returns true if given tag exists in the repository.
func (*Repository) LineBlame ¶
func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error)
LineBlame returns the latest commit at the given line
func (*Repository) RemoveRemote ¶
func (repo *Repository) RemoveRemote(name string) error
RemoveRemote removes a remote from repository.
func (*Repository) SetDefaultBranch ¶
func (repo *Repository) SetDefaultBranch(name string) error
SetDefaultBranch sets default branch of repository.
type SHA1 ¶
type SHA1 [20]byte
SHA1 a git commit name
func MustIDFromString ¶
MustIDFromString always creates a new sha from a ID with no validation of input.
func NewIDFromString ¶
NewIDFromString creates a new SHA1 from a ID string of length 40.
type SubModuleFile ¶
type SubModuleFile struct { *Commit // contains filtered or unexported fields }
SubModuleFile represents a file with submodule type.
func NewSubModuleFile ¶
func NewSubModuleFile(c *Commit, refURL, refID string) *SubModuleFile
NewSubModuleFile create a new submodule file
type Tag ¶
type Tag struct { Name string ID SHA1 Object SHA1 // The id of this commit object Type string Tagger *Signature Message string // contains filtered or unexported fields }
Tag represents a Git tag.
type Tree ¶
type Tree struct { ID SHA1 // contains filtered or unexported fields }
Tree represents a flat directory listing.
func NewTree ¶
func NewTree(repo *Repository, id SHA1) *Tree
NewTree create a new tree according the repository and commit id
func (*Tree) GetBlobByPath ¶
GetBlobByPath get the blob object accroding the path
func (*Tree) GetTreeEntryByPath ¶
GetTreeEntryByPath get the tree entries accroding the sub dir
func (*Tree) ListEntries ¶
ListEntries returns all entries of current tree.
func (*Tree) ListEntriesRecursive ¶
ListEntriesRecursive returns all entries of current tree recursively including all subtrees
type TreeEntry ¶
type TreeEntry struct { ID SHA1 Type ObjectType // contains filtered or unexported fields }
TreeEntry the leaf in the git tree
func ParseTreeEntries ¶
ParseTreeEntries parses the output of a `git ls-tree` command.
func (*TreeEntry) FollowLink ¶
FollowLink returns the entry pointed to by a symlink
func (*TreeEntry) GetSubJumpablePathName ¶
GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory )
func (*TreeEntry) IsSubModule ¶
IsSubModule if the entry is a sub module
Source Files ¶
- blob.go
- cache.go
- command.go
- commit.go
- commit_archive.go
- commit_info.go
- doc.go
- error.go
- git.go
- hook.go
- parse.go
- ref.go
- repo.go
- repo_blame.go
- repo_blob.go
- repo_branch.go
- repo_commit.go
- repo_hook.go
- repo_object.go
- repo_pull.go
- repo_ref.go
- repo_tag.go
- repo_tree.go
- sha1.go
- signature.go
- submodule.go
- tag.go
- tree.go
- tree_blob.go
- tree_entry.go
- utils.go