1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-09 12:07:20 +00:00

Fix git empty check and HEAD request (#33690)

This commit is contained in:
wxiaoguang
2025-02-24 10:11:29 +08:00
committed by GitHub
parent 8ae46d9684
commit 56a0a9c750
4 changed files with 36 additions and 16 deletions

View File

@ -60,12 +60,20 @@ func TestEmptyRepoAddFile(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user30")
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadRepository)
// test web page
req := NewRequest(t, "GET", "/user30/empty")
resp := session.MakeRequest(t, req, http.StatusOK)
bodyString := resp.Body.String()
assert.Contains(t, bodyString, "empty-repo-guide")
assert.True(t, test.IsNormalPageCompleted(bodyString))
// test api
req = NewRequest(t, "GET", "/api/v1/repos/user30/empty/raw/main/README.md").AddTokenAuth(token)
session.MakeRequest(t, req, http.StatusNotFound)
// create a new file
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"]`)