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

Commit ee1a397

Browse files
cez81appleboy
authored andcommitted
Panic if Git version is < GitVersionRequired (#46)
* Panic if Git version is < GitVersionRequired * Update GitVersionRequired comment * Correct copyright
1 parent d5e562c commit ee1a397

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2015 The Gogs Authors. All rights reserved.
2+
// Copyright 2017 The Gitea Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
45

@@ -8,6 +9,8 @@ import (
89
"fmt"
910
"strings"
1011
"time"
12+
13+
"github.com/mcuadros/go-version"
1114
)
1215

1316
// Version return this package's current version
@@ -21,6 +24,8 @@ var (
2124
Debug = false
2225
// Prefix the log prefix
2326
Prefix = "[git-module] "
27+
// GitVersionRequired is the minimum Git version required
28+
GitVersionRequired = "1.7.10"
2429
)
2530

2631
func log(format string, args ...interface{}) {
@@ -66,7 +71,13 @@ func BinVersion() (string, error) {
6671
}
6772

6873
func init() {
69-
BinVersion()
74+
gitVersion, err := BinVersion()
75+
if err != nil {
76+
panic(fmt.Sprintf("Git version missing: %v", err))
77+
}
78+
if version.Compare(gitVersion, GitVersionRequired, "<") {
79+
panic(fmt.Sprintf("Git version not supported. Requires version > %v", GitVersionRequired))
80+
}
7081
}
7182

7283
// Fsck verifies the connectivity and validity of the objects in the database

0 commit comments

Comments
 (0)