當前位置: 首頁>>代碼示例>>Golang>>正文


Golang com.ExecCmdDirBytes函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。