Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yp05327 opened this issue May 31, 2023 · 2 comments · Fixed by #25017
Closed

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

yp05327 opened this issue May 31, 2023 · 2 comments · Fixed by #25017
Labels

Comments

@yp05327
Copy link
Contributor

yp05327 commented 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

@yardenshoham
Copy link
Member

cc @wxiaoguang

@wxiaoguang
Copy link
Contributor

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

lunny pushed a commit that referenced this issue May 31, 2023
…25017)

Fix #25014

Only API needs this fix. On the Web UI, users could only add new file on
the default branch.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants