本文整理汇总了Golang中github.com/Unknwon/com.ExecCmdDirBytes函数的典型用法代码示例。如果您正苦于以下问题:Golang ExecCmdDirBytes函数的具体用法?Golang ExecCmdDirBytes怎么用?Golang ExecCmdDirBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExecCmdDirBytes函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Data
func (b *Blob) Data() (io.Reader, error) {
stdout, stderr, err := com.ExecCmdDirBytes(b.repo.Path, "git", "show", b.ID.String())
if err != nil {
return nil, errors.New(string(stderr))
}
return bytes.NewBuffer(stdout), nil
}
开发者ID:Janfred,项目名称:gogs,代码行数:7,代码来源:blob.go
示例2: commitsByRange
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(),
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat)
if err != nil {
return nil, errors.New(string(stderr))
}
return parsePrettyFormatLog(repo, stdout)
}
开发者ID:noikiy,项目名称:gitea,代码行数:8,代码来源:repo_commit.go
示例3: CommitsByFileAndRange
func (repo *Repository) CommitsByFileAndRange(branch, file string, page int) (*list.List, error) {
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", branch,
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat, "--", file)
if err != nil {
return nil, errors.New(string(stderr))
}
return parsePrettyFormatLog(repo, stdout)
}
开发者ID:noikiy,项目名称:gitea,代码行数:8,代码来源:repo_commit.go
示例4: GetPatch
// GetPatch generates and returns patch data between given branches.
func (repo *Repository) GetPatch(mergeBase, headBranch string) ([]byte, error) {
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", mergeBase, headBranch)
if err != nil {
return nil, concatenateError(err, string(stderr))
}
return stdout, nil
}
开发者ID:hopehook,项目名称:gogs,代码行数:9,代码来源:repo_pull.go
示例5: searchCommits
func (repo *Repository) searchCommits(id sha1, keyword string) (*list.List, error) {
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(), "-100",
"-i", "--grep="+keyword, prettyLogFormat)
if err != nil {
return nil, err
} else if len(stderr) > 0 {
return nil, errors.New(string(stderr))
}
return parsePrettyFormatLog(repo, stdout)
}
开发者ID:noikiy,项目名称:gitea,代码行数:10,代码来源:repo_commit.go
示例6: GetPatch
// GetPatch generates and returns patch data between given branches.
func (repo *Repository) GetPatch(basePath, baseBranch, headBranch string) ([]byte, error) {
// Add a temporary remote.
tmpRemote := com.ToStr(time.Now().UnixNano())
_, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "remote", "add", "-f", tmpRemote, basePath)
if err != nil {
return nil, fmt.Errorf("add base as remote: %v", concatenateError(err, string(stderr)))
}
defer func() {
com.ExecCmdDir(repo.Path, "git", "remote", "remove", tmpRemote)
}()
var stdout []byte
remoteBranch := "remotes/" + tmpRemote + "/" + baseBranch
stdout, stderr, err = com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", remoteBranch, headBranch)
if err != nil {
return nil, concatenateError(err, string(stderr))
}
return stdout, nil
}
开发者ID:GoNuuts,项目名称:gogs,代码行数:21,代码来源:repo_pull.go
示例7: ListEntries
func (t *Tree) ListEntries(relpath string) (Entries, error) {
if t.entriesParsed {
return t.entries, nil
}
t.entriesParsed = true
stdout, _, err := com.ExecCmdDirBytes(t.repo.Path,
"git", "ls-tree", t.Id.String())
if err != nil {
return nil, err
}
t.entries, err = parseTreeData(t, stdout)
return t.entries, err
}
开发者ID:felipelovato,项目名称:gogs,代码行数:14,代码来源:tree.go
示例8: commitsCount
func (repo *Repository) commitsCount(id sha1) (int, error) {
if gitVer.LessThan(MustParseVersion("1.8.0")) {
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", "--pretty=format:''", id.String())
if err != nil {
return 0, errors.New(string(stderr))
}
return len(bytes.Split(stdout, []byte("\n"))), nil
}
stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count", id.String())
if err != nil {
return 0, errors.New(stderr)
}
return com.StrTo(strings.TrimSpace(stdout)).Int()
}
开发者ID:noikiy,项目名称:gitea,代码行数:15,代码来源:repo_commit.go
示例9: ListEntries
func (t *Tree) ListEntries(relpath string) (Entries, error) {
if t.entriesParsed {
return t.entries, nil
}
t.entriesParsed = true
stdout, stderr, err := com.ExecCmdDirBytes(t.repo.Path,
"git", "ls-tree", t.Id.String())
if err != nil {
if strings.Contains(err.Error(), "exit status 128") {
return nil, errors.New(strings.TrimSpace(string(stderr)))
}
return nil, err
}
t.entries, err = parseTreeData(t, stdout)
return t.entries, err
}
开发者ID:noikiy,项目名称:gogs,代码行数:17,代码来源:tree.go
示例10: getTag
func (repo *Repository) getTag(id sha1) (*Tag, error) {
if repo.tagCache != nil {
if t, ok := repo.tagCache[id]; ok {
return t, nil
}
} else {
repo.tagCache = make(map[sha1]*Tag, 10)
}
// Get tag type.
tp, stderr, err := com.ExecCmdDir(repo.Path, "git", "cat-file", "-t", id.String())
if err != nil {
return nil, errors.New(stderr)
}
tp = strings.TrimSpace(tp)
// Tag is a commit.
if ObjectType(tp) == COMMIT {
tag := &Tag{
Id: id,
Object: id,
Type: string(COMMIT),
repo: repo,
}
repo.tagCache[id] = tag
return tag, nil
}
// Tag with message.
data, bytErr, err := com.ExecCmdDirBytes(repo.Path, "git", "cat-file", "-p", id.String())
if err != nil {
return nil, errors.New(string(bytErr))
}
tag, err := parseTagData(data)
if err != nil {
return nil, err
}
tag.Id = id
tag.repo = repo
repo.tagCache[id] = tag
return tag, nil
}
开发者ID:noikiy,项目名称:gogs,代码行数:45,代码来源:repo_tag.go
示例11: getCommit
func (repo *Repository) getCommit(id sha1) (*Commit, error) {
if repo.commitCache != nil {
if c, ok := repo.commitCache[id]; ok {
return c, nil
}
} else {
repo.commitCache = make(map[sha1]*Commit, 10)
}
data, bytErr, err := com.ExecCmdDirBytes(repo.Path, "git", "cat-file", "-p", id.String())
if err != nil {
return nil, errors.New(err.Error() + ": " + string(bytErr))
}
commit, err := parseCommitData(data)
if err != nil {
return nil, err
}
commit.repo = repo
commit.Id = id
repo.commitCache[id] = commit
return commit, nil
}
开发者ID:noikiy,项目名称:gitea,代码行数:24,代码来源:repo_commit.go
注:本文中的github.com/Unknwon/com.ExecCmdDirBytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论