]> source.dussan.org Git - gitea.git/commitdiff
Work on #476
authorUnknwon <joe2010xtmf@163.com>
Tue, 16 Sep 2014 15:29:53 +0000 (11:29 -0400)
committerUnknwon <joe2010xtmf@163.com>
Tue, 16 Sep 2014 15:29:53 +0000 (11:29 -0400)
models/repo.go
modules/git/repo_commit.go
modules/git/version.go

index a8e53dbcd7378579ee990ab6974a0361b5b0cdef..2e16270431afb96e0c549edc7a338d0cc7d38885 100644 (file)
@@ -100,7 +100,7 @@ func NewRepoContext() {
        if err != nil {
                log.Fatal(4, "Fail to parse required Git version: %v", err)
        }
-       if ver.Compare(reqVer) == -1 {
+       if ver.LessThan(reqVer) {
                log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1")
        }
 
index c9258927bb132b66d1b3d147385d5acaaf161508..cd0181c481b98128090401c6dac5d3d5f1999bf3 100644 (file)
@@ -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))
index 653503c03cb12aff9a4036ac712ff68c8ac895b5..546397aa62667fe26612919209bc7ec5285ed54f 100644 (file)
@@ -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 {