1
0
Fork 0
forked from forgejo/forgejo

Update repo's default branch when adding new files in an empty one (#25017)

Fix #25014

Only API needs this fix. On the Web UI, users could only add new file on
the default branch.
This commit is contained in:
wxiaoguang 2023-05-31 17:07:51 +08:00 committed by GitHub
parent a5acec329e
commit a90988d63f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View file

@ -137,4 +137,10 @@ func TestEmptyRepoAddFileByAPI(t *testing.T) {
req = NewRequest(t, "GET", "/user30/empty/src/branch/new_branch/new-file.txt")
resp = session.MakeRequest(t, req, http.StatusOK)
assert.Contains(t, resp.Body.String(), "newly-added-api-file")
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)
}