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

Closed
opened 2025-11-02 09:22:36 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @yp05327 on GitHub (May 31, 2023).

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

Originally created by @yp05327 on GitHub (May 31, 2023). ### Description Related to: https://github.com/go-gitea/gitea/actions/runs/5086056277/jobs/9140155510 You can add the following test code in `TestEmptyRepoAddFileByAPI`: ``` golang 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](https://github.com/go-gitea/gitea/assets/18380374/9fcc3b5e-8299-4ec6-b276-7444a7d3aedd) No sure whether it is by design. But in web ui will have some bugs: ![image](https://github.com/go-gitea/gitea/assets/18380374/85d8df03-8f7f-41cb-88ad-c1d4d2e714a8) ![image](https://github.com/go-gitea/gitea/assets/18380374/079620ce-aa16-438d-8206-06a2c8476900) ![image](https://github.com/go-gitea/gitea/assets/18380374/b5e0e889-1e1a-4a5a-bf55-e4145870b63c) ps: not sure how to use this api correctly I got `repo is empty` error. But the file was uploaded successed. ![image](https://github.com/go-gitea/gitea/assets/18380374/ebc25fe2-4b6f-47f7-b153-21135f6a5f33) ![image](https://github.com/go-gitea/gitea/assets/18380374/71276ad4-ad2b-4ae1-bb72-1ee3c7d7802a) ![image](https://github.com/go-gitea/gitea/assets/18380374/f6520eb0-8909-44da-80cb-95a7951aed2a) ### 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
GiteaMirror added the type/bug label 2025-11-02 09:22:36 -06:00
Author
Owner

@yardenshoham commented on GitHub (May 31, 2023):

cc @wxiaoguang

@yardenshoham commented on GitHub (May 31, 2023): cc @wxiaoguang
Author
Owner

@wxiaoguang commented on GitHub (May 31, 2023):

Let's fix it: Update repo's default branch when adding new files in an empty one #25017

@wxiaoguang commented on GitHub (May 31, 2023): Let's fix it: Update repo's default branch when adding new files in an empty one #25017
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10937