From 355714ad4307e385d9524e80c1f2d47f55a16da4 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Nov 2017 23:05:43 +1300 Subject: [PATCH 01/11] Add an head ref for the sake of using self repo for testing --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index a4812caf9..6e3358be7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,6 +14,7 @@ pipeline: image: webhippie/golang:edge pull: true commands: + - git update-ref refs/heads/test HEAD - make clean - make vet - make lint From 20222c41ca9f4c1ffb29eda1bd7d37a1a13cb9f4 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Nov 2017 22:07:13 +1300 Subject: [PATCH 02/11] Add test for CommitCount --- commit_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 commit_test.go 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) +} From 3c118533cd32fb9ffc7403d80c0fe06248083eac Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Nov 2017 22:15:30 +1300 Subject: [PATCH 03/11] Add test for GetLatestCommitTime The test checks that latest commit time is before now and more recent than the commit this PR is based at Test no error is raised by time parsing and GetLatestCommitTime Print actual time when tests fail --- repo_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 repo_test.go 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) +} From 67a38f3ebbc4e02142dc0b7399a6bb95c1d57542 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Nov 2017 21:04:15 +1300 Subject: [PATCH 04/11] Add testing with git-1.7.2 --- .drone.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.drone.yml b/.drone.yml index 6e3358be7..bf7021d2c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,6 +18,22 @@ pipeline: - make clean - make vet - make lint + - git --version + - make test + - apk add --update autoconf && + apk add --update zlib-dev && + 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 && + ./configure --without-tcltk --prefix=/usr/local && + make install NO_PERL=please && + cd ../.. && + rm -rf build && + rm git.tar.gz + - hash -r + - git --version - make test - make build From 70bc2a3a725e8ddd5d53d6c65d9cf4f958db91d2 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sat, 11 Nov 2017 23:19:11 +1300 Subject: [PATCH 05/11] Accept git 1.7.2 as the minimum version Debian old old (very old) distribution (6.0 aka Squeeze) ships version 1.7.10.4. The version requirement was raised in #46 supposedly for the need of "symbolic-ref" command, but that command is supported by the 1.7.2 version too, and possibly even older versions. --- git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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{}) { From 176547939295b4bcf1a8b240fd3f088af62508ae Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 24 Nov 2017 18:16:42 +0100 Subject: [PATCH 06/11] Reduce output from drone, add comments Reduce steps, concatenating them in logical steps --- .drone.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.drone.yml b/.drone.yml index bf7021d2c..319cd72a0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,23 +18,23 @@ pipeline: - make clean - make vet - make lint - - git --version - - make test - - apk add --update autoconf && - apk add --update zlib-dev && + # Test with latest git version + - git --version && make test + # Test with git version 1.7.2 + - 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 && - ./configure --without-tcltk --prefix=/usr/local && - make install NO_PERL=please && + { autoconf 2> err || cat err; } && + ./configure --without-tcltk --prefix=/usr/local > /dev/null && + { make install NO_PERL=please > /dev/null 2> err || cat err; } && cd ../.. && - rm -rf build && - rm git.tar.gz - - hash -r - - git --version - - make test + rm -rf build git.tar.gz && + hash -r && + git --version && + make test + # Test a build (is this really needed?) - make build # coverage: From 0a4f451834ba4159e5c09be0a4202aa9f5e00237 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 24 Nov 2017 18:24:36 +0100 Subject: [PATCH 07/11] Interrupt step upon first failure --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 319cd72a0..c2a890a95 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,9 +26,9 @@ pipeline: 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; } && + { autoconf 2> err || { cat err && false; } } && ./configure --without-tcltk --prefix=/usr/local > /dev/null && - { make install NO_PERL=please > /dev/null 2> err || cat err; } && + { make install NO_PERL=please > /dev/null 2> err || { cat err && false; } } && cd ../.. && rm -rf build git.tar.gz && hash -r && From ca88fdfba48d3f12f69d0dbc4bfe6bd537e5c19b Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sat, 25 Nov 2017 16:06:49 +0100 Subject: [PATCH 08/11] Add Dockerfile for use with ci --- docker/ci/Dockerfile-git-1.7 | 11 +++++++++++ docker/ci/Makefile | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 docker/ci/Dockerfile-git-1.7 create mode 100644 docker/ci/Makefile 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 . From 30239f0b4c0b72e4f89b580f6d40bacf8bc2b8fd Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 26 Nov 2017 10:52:52 +0100 Subject: [PATCH 09/11] Use ad-hoc docker image for testing git-1.7.2 --- .drone.yml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.drone.yml b/.drone.yml index c2a890a95..f202548c4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ clone: tags: true pipeline: - testing: + testing-git-latest: image: webhippie/golang:edge pull: true commands: @@ -18,24 +18,17 @@ pipeline: - make clean - make vet - make lint - # Test with latest git version - git --version && make test - # Test with git version 1.7.2 - - 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=/usr/local > /dev/null && - { make install NO_PERL=please > /dev/null 2> err || { cat err && false; } } && - cd ../.. && - rm -rf build git.tar.gz && - hash -r && - git --version && - make test - # Test a build (is this really needed?) - make build + testing-git-1.7: + image: docker.kbt.io/gitea-git-ci:1.7 + pull: true + commands: + - git update-ref refs/heads/test HEAD + - make clean + - make vet + - make lint + - PATH=/opt/git-1.7.2/bin git --version && make test # coverage: # image: plugins/coverage:1 From 5ff1be1ee96b0cbf8f8dc46a28746fed3675aa33 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 26 Nov 2017 13:41:18 +0100 Subject: [PATCH 10/11] Avoid running build/vet/clean twice --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index f202548c4..9fb98205f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,24 +10,24 @@ clone: tags: true pipeline: - testing-git-latest: + test-general: image: webhippie/golang:edge pull: true commands: - - git update-ref refs/heads/test HEAD - make clean - make vet - make lint - - git --version && 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 - - make clean - - make vet - - make lint - PATH=/opt/git-1.7.2/bin git --version && make test # coverage: From 9c1fd83a2a1b11e76225913ea85d76e7413f84d3 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 26 Nov 2017 21:08:05 +0100 Subject: [PATCH 11/11] Set HEAD ref also in testing-1-7 step --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 9fb98205f..b531bdb6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,6 +28,7 @@ pipeline: 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: