diff options
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/repo_commit.go | 2 | ||||
-rw-r--r-- | modules/git/version.go | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index c9258927..cd0181c4 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -137,7 +137,7 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) { } func (repo *Repository) commitsCount(id sha1) (int, error) { - if gitVer.Compare(MustParseVersion("1.8.0")) == -1 { + 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)) diff --git a/modules/git/version.go b/modules/git/version.go index 653503c0..546397aa 100644 --- a/modules/git/version.go +++ b/modules/git/version.go @@ -47,7 +47,7 @@ func MustParseVersion(verStr string) *Version { } // Compare compares two versions, -// it returns 1 if original is greater, 1 if original is smaller, 0 if equal. +// it returns 1 if original is greater, -1 if original is smaller, 0 if equal. func (v *Version) Compare(that *Version) int { if v.Major > that.Major { return 1 @@ -70,6 +70,10 @@ func (v *Version) Compare(that *Version) int { return 0 } +func (v *Version) LessThan(that *Version) bool { + return v.Compare(that) < 0 +} + // GetVersion returns current Git version installed. func GetVersion() (*Version, error) { if gitVer != nil { |