From facfbc74cdcac005e17e6716d5a5d53eb538c801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Tue, 18 Apr 2017 11:16:07 +0200 Subject: [PATCH 1/3] Panic if Git version is < GitVersionRequired --- git.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/git.go b/git.go index 2cea1dc1d..7b74cc646 100644 --- a/git.go +++ b/git.go @@ -1,4 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2017 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -8,6 +9,8 @@ import ( "fmt" "strings" "time" + + "github.com/mcuadros/go-version" ) // Version return this package's current version @@ -21,6 +24,8 @@ var ( Debug = false // Prefix the log prefix Prefix = "[git-module] " + // Minimum Git version required + GitVersionRequired = "1.7.10" ) func log(format string, args ...interface{}) { @@ -66,7 +71,13 @@ func BinVersion() (string, error) { } func init() { - BinVersion() + gitVersion, err := BinVersion() + if err != nil { + panic(fmt.Sprintf("Git version missing: %v", err)) + } + if version.Compare(gitVersion, GitVersionRequired, "<") { + panic(fmt.Sprintf("Git version not supported. Requires version > %v", GitVersionRequired)) + } } // Fsck verifies the connectivity and validity of the objects in the database From 42d287547bac2ace0def897ed1e3797bd7ede998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Tue, 18 Apr 2017 11:35:57 +0200 Subject: [PATCH 2/3] Update GitVersionRequired comment --- git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.go b/git.go index 7b74cc646..db9d30dd4 100644 --- a/git.go +++ b/git.go @@ -24,7 +24,7 @@ var ( Debug = false // Prefix the log prefix Prefix = "[git-module] " - // Minimum Git version required + // GitVersionRequired is the minimum Git version required GitVersionRequired = "1.7.10" ) From 10e8c427fb361d65185d227d60e85c8f8d61111e Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 18 Apr 2017 23:25:33 +0200 Subject: [PATCH 3/3] Correct copyright --- git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.go b/git.go index db9d30dd4..2466370b6 100644 --- a/git.go +++ b/git.go @@ -1,5 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. -// Copyright 2017 The Gogs Authors. All rights reserved. +// 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.