本文整理匯總了Golang中github.com/libgit2/git2go.Repository.LookupCommit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repository.LookupCommit方法的具體用法?Golang Repository.LookupCommit怎麽用?Golang Repository.LookupCommit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/libgit2/git2go.Repository
的用法示例。
在下文中一共展示了Repository.LookupCommit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewTreeFSRoot
// NewTreeFS creates a git Tree FS. The treeish should resolve to tree SHA1.
func NewTreeFSRoot(repo *git.Repository, treeish string, opts *GitFSOptions) (nodefs.Node, error) {
obj, err := repo.RevparseSingle(treeish)
if err != nil {
return nil, err
}
defer obj.Free()
var treeId *git.Oid
switch obj.Type() {
case git.ObjectCommit:
commit, err := repo.LookupCommit(obj.Id())
if err != nil {
return nil, err
}
treeId = commit.TreeId()
case git.ObjectTree:
treeId = obj.Id()
default:
return nil, fmt.Errorf("gitfs: unsupported object type %d", obj.Type())
}
if opts == nil {
opts = &GitFSOptions{
Lazy: true,
Disk: false,
}
}
if opts.TempDir == "" {
opts.TempDir, err = ioutil.TempDir("", "gitfs")
if err != nil {
return nil, err
}
}
t := &treeFS{
repo: repo,
opts: *opts,
}
root := t.newDirNode(treeId)
return root, nil
}