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

Panic if Git version is < GitVersionRequired #46

Merged
merged 3 commits into from
Apr 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion git.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2015 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.

Expand All @@ -8,6 +9,8 @@ import (
"fmt"
"strings"
"time"

"github.com/mcuadros/go-version"
)

// Version return this package's current version
Expand All @@ -21,6 +24,8 @@ var (
Debug = false
// Prefix the log prefix
Prefix = "[git-module] "
// GitVersionRequired is the minimum Git version required
GitVersionRequired = "1.7.10"
)

func log(format string, args ...interface{}) {
Expand Down Expand Up @@ -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
Expand Down