Skip to content

Commit 5cc275b

Browse files
appleboylunny
authored andcommitted
feat: add git version on admin panel. (#921)
1 parent 091f063 commit 5cc275b

File tree

7 files changed

+14
-3
lines changed

7 files changed

+14
-3
lines changed

models/repo.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ func NewRepoContext() {
135135
}
136136

137137
// Check Git version.
138-
gitVer, err := git.BinVersion()
138+
var err error
139+
setting.Git.Version, err = git.BinVersion()
139140
if err != nil {
140141
log.Fatal(4, "Failed to get Git version: %v", err)
141142
}
142143

143-
log.Info("Git Version: %s", gitVer)
144-
if version.Compare("1.7.1", gitVer, ">") {
144+
log.Info("Git Version: %s", setting.Git.Version)
145+
if version.Compare("1.7.1", setting.Git.Version, ">") {
145146
log.Fatal(4, "Gitea requires Git version greater or equal to 1.7.1")
146147
}
147148

modules/setting/setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ var (
354354

355355
// Git settings
356356
Git = struct {
357+
Version string `ini:"-"`
357358
DisableDiffHighlight bool
358359
MaxGitDiffLines int
359360
MaxGitDiffLineCharacters int

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ config.offline_mode = Offline Mode
11171117
config.disable_router_log = Disable Router Log
11181118
config.run_user = Run User
11191119
config.run_mode = Run Mode
1120+
config.git_version = Git Version
11201121
config.repo_root_path = Repository Root Path
11211122
config.lfs_root_path = LFS Root Path
11221123
config.static_file_root_path = Static File Root Path

options/locale/locale_zh-HK.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ config.offline_mode=離線模式
10451045
config.disable_router_log=關閉路由日誌
10461046
config.run_user=執行用戶
10471047
config.run_mode=執行模式
1048+
config.git_version=Git 版本
10481049
config.repo_root_path=儲存庫目錄
10491050
config.static_file_root_path=靜態檔案目錄
10501051
config.log_file_root_path=日誌檔案目錄

options/locale/locale_zh-TW.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ config.offline_mode=離線模式
10451045
config.disable_router_log=關閉路由日誌
10461046
config.run_user=執行用戶
10471047
config.run_mode=執行模式
1048+
config.git_version=Git 版本
10481049
config.repo_root_path=儲存庫目錄
10491050
config.static_file_root_path=靜態檔案目錄
10501051
config.log_file_root_path=日誌檔案目錄

routers/admin/admin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func Config(ctx *context.Context) {
200200
ctx.Data["DisableRouterLog"] = setting.DisableRouterLog
201201
ctx.Data["RunUser"] = setting.RunUser
202202
ctx.Data["RunMode"] = strings.Title(macaron.Env)
203+
ctx.Data["GitVersion"] = setting.Git.Version
203204
ctx.Data["RepoRootPath"] = setting.RepoRootPath
204205
ctx.Data["StaticRootPath"] = setting.StaticRootPath
205206
ctx.Data["LogRootPath"] = setting.LogRootPath

templates/admin/config.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
<div class="ui divider"></div>
3434

35+
<dt>{{.i18n.Tr "admin.config.git_version"}}</dt>
36+
<dd>{{.GitVersion}}</dd>
37+
38+
<div class="ui divider"></div>
39+
3540
<dt>{{.i18n.Tr "admin.config.repo_root_path"}}</dt>
3641
<dd>{{.RepoRootPath}}</dd>
3742
<dt>{{.i18n.Tr "admin.config.static_file_root_path"}}</dt>

0 commit comments

Comments
 (0)