This commit is contained in:
Unknwon 2014-09-16 10:10:33 -04:00
parent c1ceec45da
commit 0d9c41be7d
7 changed files with 78 additions and 17 deletions

View file

@ -137,6 +137,14 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) {
}
func (repo *Repository) commitsCount(id sha1) (int, error) {
if gitVer.Compare(MustParseVersion("1.8.0")) == -1 {
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)