Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no branch redirection loop #33100

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ create_new_repo_command = Creating a new repository on the command line
push_exist_repo = Pushing an existing repository from the command line
empty_message = This repository does not contain any content.
broken_message = The Git data underlying this repository cannot be read. Contact the administrator of this instance or delete this repository.
no_branch = This repository doesn’t have any branches.

code = Code
code.desc = Access source code, files, commits and branches.
Expand Down
5 changes: 5 additions & 0 deletions routers/web/repo/view_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ func handleRepoEmptyOrBroken(ctx *context.Context) {
return
}

if v, ok := ctx.Data["BranchesCount"]; ok && v.(int64) == 0 {
ctx.HTML(http.StatusOK, tplRepoEMPTY)
return
}

// the repo is not really empty, so we should update the modal in database
// such problem may be caused by:
// 1) an error occurs during pushing/receiving. 2) the user replaces an empty git repo manually
Expand Down
12 changes: 9 additions & 3 deletions templates/repo/empty.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
</div>
{{end}}
{{if .Repository.IsBroken}}
<div class="ui segment center">
{{ctx.Locale.Tr "repo.broken_message"}}
</div>
{{if (not .BranchesCount)}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why in if IsBroken block?

BranchesCount==0 means IsBroken==true?

<div class="ui segment center">
{{ctx.Locale.Tr "repo.no_branch"}}
</div>
{{else}}
<div class="ui segment center">
{{ctx.Locale.Tr "repo.broken_message"}}
</div>
{{end}}
{{else if .CanWriteCode}}
<h4 class="ui top attached header">
{{ctx.Locale.Tr "repo.quick_guide"}}
Expand Down
Loading