mirror of https://github.com/go-gitea/gitea.git
Fix repo empty guide (#33114)
This commit is contained in:
parent
3c1c508421
commit
40765b5d45
|
@ -250,6 +250,7 @@ func handleRepoEmptyOrBroken(ctx *context.Context) {
|
|||
showEmpty = true // it is not really empty, but there is no branch
|
||||
// at the moment, other repo units like "actions" are not able to handle such case,
|
||||
// so we just mark the repo as empty to prevent from displaying these units.
|
||||
ctx.Data["RepoHasContentsWithoutBranch"] = true
|
||||
updateContextRepoEmptyAndStatus(ctx, true, repo_model.RepositoryReady)
|
||||
} else {
|
||||
// the repo is actually not empty and has branches, need to update the database later
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
{{if .Repository.IsBroken}}
|
||||
<div class="ui segment center">{{ctx.Locale.Tr "repo.broken_message"}}</div>
|
||||
{{else if .Repository.IsEmpty}}
|
||||
{{else if .RepoHasContentsWithoutBranch}}
|
||||
<div class="ui segment center">{{ctx.Locale.Tr "repo.no_branch"}}</div>
|
||||
{{else if .CanWriteCode}}
|
||||
<h4 class="ui top attached header">{{ctx.Locale.Tr "repo.quick_guide"}}</h4>
|
||||
|
|
|
@ -58,8 +58,12 @@ func TestEmptyRepoAddFile(t *testing.T) {
|
|||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
session := loginUser(t, "user30")
|
||||
req := NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
||||
req := NewRequest(t, "GET", "/user30/empty")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), "empty-repo-guide")
|
||||
|
||||
req = NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
doc := NewHTMLParser(t, resp.Body).Find(`input[name="commit_choice"]`)
|
||||
assert.Empty(t, doc.AttrOr("checked", "_no_"))
|
||||
req = NewRequestWithValues(t, "POST", "/user30/empty/_new/"+setting.Repository.DefaultBranch, map[string]string{
|
||||
|
|
Loading…
Reference in New Issue