mirror of
https://github.com/go-gitea/gitea
synced 2025-07-07 02:57:20 +00:00
Do not show 500 error when default branch doesn't exist (#34096)
Fix #34090
This commit is contained in:
@ -9,7 +9,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -61,5 +63,14 @@ func TestRepoActivity(t *testing.T) {
|
||||
// Should be 3 new issues
|
||||
list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
|
||||
assert.Len(t, list.Nodes, 3)
|
||||
|
||||
// Non-existing default branch
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: "repo1"})
|
||||
repo1.DefaultBranch = "no-such-branch"
|
||||
_, _ = db.GetEngine(t.Context()).Cols("default_branch").Update(repo1)
|
||||
req = NewRequest(t, "GET", "/user2/repo1/activity")
|
||||
req.Header.Add("Accept", "text/html")
|
||||
resp = session.MakeRequest(t, req, http.StatusNotFound)
|
||||
assert.Contains(t, resp.Body.String(), `Default branch "no-such-branch" does not exist.`)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user