diff --git a/.drone.yml b/.drone.yml index a4812caf9..b531bdb6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,15 +10,26 @@ clone: tags: true pipeline: - testing: + test-general: image: webhippie/golang:edge pull: true commands: - make clean - make vet - make lint - - make test - make build + testing-git-latest: + image: webhippie/golang:edge + pull: true + commands: + - git update-ref refs/heads/test HEAD + - git --version && make test + testing-git-1.7: + image: docker.kbt.io/gitea-git-ci:1.7 + pull: true + commands: + - git update-ref refs/heads/test HEAD + - PATH=/opt/git-1.7.2/bin git --version && make test # coverage: # image: plugins/coverage:1 diff --git a/commit_test.go b/commit_test.go new file mode 100644 index 000000000..a30f2b859 --- /dev/null +++ b/commit_test.go @@ -0,0 +1,15 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package git + +import ( + "testing" + "github.com/stretchr/testify/assert" +) + +func TestCommitsCount(t *testing.T) { + commitsCount, _ := CommitsCount(".", "d86a90f801dbe279db095437a8c7ea42c60e8d98") + assert.Equal(t, int64(3), commitsCount) +} diff --git a/docker/ci/Dockerfile-git-1.7 b/docker/ci/Dockerfile-git-1.7 new file mode 100644 index 000000000..82260020a --- /dev/null +++ b/docker/ci/Dockerfile-git-1.7 @@ -0,0 +1,11 @@ +FROM webhippie/golang:edge +RUN apk add --update autoconf zlib-dev > /dev/null && \ + mkdir build && \ + curl -sL "https://github.com/git/git/archive/v1.7.2.tar.gz" -o git.tar.gz && \ + tar -C build -xzf git.tar.gz && \ + cd build/git-1.7.2 && \ + { autoconf 2> err || { cat err && false; } } && \ + ./configure --without-tcltk --prefix=/opt/git-1.7.2 > /dev/null && \ + { make install NO_PERL=please > /dev/null 2> err || { cat err && false; } } && \ + cd ../.. && \ + rm -rf build git.tar.gz \ diff --git a/docker/ci/Makefile b/docker/ci/Makefile new file mode 100644 index 000000000..3d03767ca --- /dev/null +++ b/docker/ci/Makefile @@ -0,0 +1,2 @@ +git-1.7: + docker build -t gitea/ci:git-1.7 -f Dockerfile-git-1.7 . diff --git a/git.go b/git.go index 9ec20c97e..150b80fb0 100644 --- a/git.go +++ b/git.go @@ -25,7 +25,7 @@ var ( // Prefix the log prefix Prefix = "[git-module] " // GitVersionRequired is the minimum Git version required - GitVersionRequired = "1.8.1.6" + GitVersionRequired = "1.7.2" ) func log(format string, args ...interface{}) { diff --git a/repo_test.go b/repo_test.go new file mode 100644 index 000000000..971687f35 --- /dev/null +++ b/repo_test.go @@ -0,0 +1,25 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package git + +import ( + "testing" + "time" + "github.com/stretchr/testify/assert" +) + +func TestGetLatestCommitTime(t *testing.T) { + lct, err := GetLatestCommitTime(".") + assert.NoError(t, err) + // Time is in the past + now := time.Now() + assert.True(t, lct.Unix() < now.Unix(), "%d not smaller than %d", lct, now) + // Time is after Mon Oct 23 03:52:09 2017 +0300 + // which is the time of commit + // d47b98c44c9a6472e44ab80efe65235e11c6da2a + refTime, err := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Mon Oct 23 03:52:09 2017 +0300") + assert.NoError(t, err) + assert.True(t, lct.Unix() > refTime.Unix(), "%d not greater than %d", lct, refTime) +}