Skip to content

Commit 9f80d1d

Browse files
committed
Fix no branch redirection loop
1 parent 188e0ee commit 9f80d1d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ create_new_repo_command = Creating a new repository on the command line
12351235
push_exist_repo = Pushing an existing repository from the command line
12361236
empty_message = This repository does not contain any content.
12371237
broken_message = The Git data underlying this repository cannot be read. Contact the administrator of this instance or delete this repository.
1238+
no_branch = This repository doesn’t have any branches.
12381239
12391240
code = Code
12401241
code.desc = Access source code, files, commits and branches.

routers/web/repo/view_home.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ func handleRepoEmptyOrBroken(ctx *context.Context) {
240240
return
241241
}
242242

243+
if v, ok := ctx.Data["BranchesCount"]; ok && v.(int64) == 0 {
244+
ctx.HTML(http.StatusOK, tplRepoEMPTY)
245+
return
246+
}
247+
243248
// the repo is not really empty, so we should update the modal in database
244249
// such problem may be caused by:
245250
// 1) an error occurs during pushing/receiving. 2) the user replaces an empty git repo manually

templates/repo/empty.tmpl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
</div>
1616
{{end}}
1717
{{if .Repository.IsBroken}}
18-
<div class="ui segment center">
19-
{{ctx.Locale.Tr "repo.broken_message"}}
20-
</div>
18+
{{if (not .BranchesCount)}}
19+
<div class="ui segment center">
20+
{{ctx.Locale.Tr "repo.no_branch"}}
21+
</div>
22+
{{else}}
23+
<div class="ui segment center">
24+
{{ctx.Locale.Tr "repo.broken_message"}}
25+
</div>
26+
{{end}}
2127
{{else if .CanWriteCode}}
2228
<h4 class="ui top attached header">
2329
{{ctx.Locale.Tr "repo.quick_guide"}}

0 commit comments

Comments
 (0)