Skip to content

Upload a new file to an empty repo by API will not update repo's default branch #25014

Closed
@yp05327

Description

Description

Related to: https://github.com/go-gitea/gitea/actions/runs/5086056277/jobs/9140155510

You can add the following test code in TestEmptyRepoAddFileByAPI:

req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/user30/empty?token=%s", token))
resp = session.MakeRequest(t, req, http.StatusOK)
var apiRepo api.Repository
DecodeJSON(t, resp, &apiRepo)
assert.Equal(t, "new_branch", apiRepo.DefaultBranch)

Result:
image

No sure whether it is by design. But in web ui will have some bugs:
image
image
image

ps: not sure how to use this api correctly
I got repo is empty error. But the file was uploaded successed.
image
image
image

Gitea Version

latest

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

build

Database

None

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions