Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit c2040d5

Browse files
strklunny
authored andcommitted
Accept git 1.7.2 as the minimum version (#90)
* Add an head ref for the sake of using self repo for testing * Add test for CommitCount * Add testing with git-1.7.2 * 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 * 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. * Reduce output from drone, add comments Reduce steps, concatenating them in logical steps * Interrupt step upon first failure * Add Dockerfile for use with ci * Use ad-hoc docker image for testing git-1.7.2 * Avoid running build/vet/clean twice * Set HEAD ref also in testing-1-7 step
1 parent 193e22e commit c2040d5

File tree

6 files changed

+67
-3
lines changed

6 files changed

+67
-3
lines changed

.drone.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,26 @@ clone:
1010
tags: true
1111

1212
pipeline:
13-
testing:
13+
test-general:
1414
image: webhippie/golang:edge
1515
pull: true
1616
commands:
1717
- make clean
1818
- make vet
1919
- make lint
20-
- make test
2120
- make build
21+
testing-git-latest:
22+
image: webhippie/golang:edge
23+
pull: true
24+
commands:
25+
- git update-ref refs/heads/test HEAD
26+
- git --version && make test
27+
testing-git-1.7:
28+
image: docker.kbt.io/gitea-git-ci:1.7
29+
pull: true
30+
commands:
31+
- git update-ref refs/heads/test HEAD
32+
- PATH=/opt/git-1.7.2/bin git --version && make test
2233

2334
# coverage:
2435
# image: plugins/coverage:1

commit_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package git
6+
7+
import (
8+
"testing"
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestCommitsCount(t *testing.T) {
13+
commitsCount, _ := CommitsCount(".", "d86a90f801dbe279db095437a8c7ea42c60e8d98")
14+
assert.Equal(t, int64(3), commitsCount)
15+
}

docker/ci/Dockerfile-git-1.7

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM webhippie/golang:edge
2+
RUN apk add --update autoconf zlib-dev > /dev/null && \
3+
mkdir build && \
4+
curl -sL "https://github.com/git/git/archive/v1.7.2.tar.gz" -o git.tar.gz && \
5+
tar -C build -xzf git.tar.gz && \
6+
cd build/git-1.7.2 && \
7+
{ autoconf 2> err || { cat err && false; } } && \
8+
./configure --without-tcltk --prefix=/opt/git-1.7.2 > /dev/null && \
9+
{ make install NO_PERL=please > /dev/null 2> err || { cat err && false; } } && \
10+
cd ../.. && \
11+
rm -rf build git.tar.gz \

docker/ci/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
git-1.7:
2+
docker build -t gitea/ci:git-1.7 -f Dockerfile-git-1.7 .

git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
// Prefix the log prefix
2626
Prefix = "[git-module] "
2727
// GitVersionRequired is the minimum Git version required
28-
GitVersionRequired = "1.8.1.6"
28+
GitVersionRequired = "1.7.2"
2929
)
3030

3131
func log(format string, args ...interface{}) {

repo_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package git
6+
7+
import (
8+
"testing"
9+
"time"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestGetLatestCommitTime(t *testing.T) {
14+
lct, err := GetLatestCommitTime(".")
15+
assert.NoError(t, err)
16+
// Time is in the past
17+
now := time.Now()
18+
assert.True(t, lct.Unix() < now.Unix(), "%d not smaller than %d", lct, now)
19+
// Time is after Mon Oct 23 03:52:09 2017 +0300
20+
// which is the time of commit
21+
// d47b98c44c9a6472e44ab80efe65235e11c6da2a
22+
refTime, err := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Mon Oct 23 03:52:09 2017 +0300")
23+
assert.NoError(t, err)
24+
assert.True(t, lct.Unix() > refTime.Unix(), "%d not greater than %d", lct, refTime)
25+
}

0 commit comments

Comments
 (0)