From 5cc275b1defc56d54bec23d1a5740c3fadcff2b0 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 13 Feb 2017 19:49:42 +0800 Subject: [PATCH] feat: add git version on admin panel. (#921) --- models/repo.go | 7 ++++--- modules/setting/setting.go | 1 + options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-HK.ini | 1 + options/locale/locale_zh-TW.ini | 1 + routers/admin/admin.go | 1 + templates/admin/config.tmpl | 5 +++++ 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/models/repo.go b/models/repo.go index 86961d68d7..7a6eaea215 100644 --- a/models/repo.go +++ b/models/repo.go @@ -135,13 +135,14 @@ func NewRepoContext() { } // Check Git version. - gitVer, err := git.BinVersion() + var err error + setting.Git.Version, err = git.BinVersion() if err != nil { log.Fatal(4, "Failed to get Git version: %v", err) } - log.Info("Git Version: %s", gitVer) - if version.Compare("1.7.1", gitVer, ">") { + log.Info("Git Version: %s", setting.Git.Version) + if version.Compare("1.7.1", setting.Git.Version, ">") { log.Fatal(4, "Gitea requires Git version greater or equal to 1.7.1") } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 747ddbf708..0e8d4a6483 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -354,6 +354,7 @@ var ( // Git settings Git = struct { + Version string `ini:"-"` DisableDiffHighlight bool MaxGitDiffLines int MaxGitDiffLineCharacters int diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7e0d3feec9..9ae5f369b2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1117,6 +1117,7 @@ config.offline_mode = Offline Mode config.disable_router_log = Disable Router Log config.run_user = Run User config.run_mode = Run Mode +config.git_version = Git Version config.repo_root_path = Repository Root Path config.lfs_root_path = LFS Root Path config.static_file_root_path = Static File Root Path diff --git a/options/locale/locale_zh-HK.ini b/options/locale/locale_zh-HK.ini index c26ed6e50a..a89b2439c8 100644 --- a/options/locale/locale_zh-HK.ini +++ b/options/locale/locale_zh-HK.ini @@ -1045,6 +1045,7 @@ config.offline_mode=離線模式 config.disable_router_log=關閉路由日誌 config.run_user=執行用戶 config.run_mode=執行模式 +config.git_version=Git 版本 config.repo_root_path=儲存庫目錄 config.static_file_root_path=靜態檔案目錄 config.log_file_root_path=日誌檔案目錄 diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index c26ed6e50a..a89b2439c8 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -1045,6 +1045,7 @@ config.offline_mode=離線模式 config.disable_router_log=關閉路由日誌 config.run_user=執行用戶 config.run_mode=執行模式 +config.git_version=Git 版本 config.repo_root_path=儲存庫目錄 config.static_file_root_path=靜態檔案目錄 config.log_file_root_path=日誌檔案目錄 diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 147982d9b6..7158a4ee91 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -200,6 +200,7 @@ func Config(ctx *context.Context) { ctx.Data["DisableRouterLog"] = setting.DisableRouterLog ctx.Data["RunUser"] = setting.RunUser ctx.Data["RunMode"] = strings.Title(macaron.Env) + ctx.Data["GitVersion"] = setting.Git.Version ctx.Data["RepoRootPath"] = setting.RepoRootPath ctx.Data["StaticRootPath"] = setting.StaticRootPath ctx.Data["LogRootPath"] = setting.LogRootPath diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index f0c349b1de..12a25e8e5d 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -32,6 +32,11 @@
+
{{.i18n.Tr "admin.config.git_version"}}
+
{{.GitVersion}}
+ +
+
{{.i18n.Tr "admin.config.repo_root_path"}}
{{.RepoRootPath}}
{{.i18n.Tr "admin.config.static_file_root_path"}}