Allow API to create file on empty repo (#19224)

This PR adds the necessary work to make it possible to create files on empty
repos using the API.

Fix #10993

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath authored and GitHub committed 2022-03-28 21:48:41 +02:00
1 parent 54961f3ac9
commit e69b7a92ed
8 files changed
+175 -117

No files matched your search

-3
View File
@@ -233,9 +233,6 @@ func CreateFile(ctx *context.APIContext) {
// "$ref": "#/responses/error"
apiOpts := web.GetForm(ctx).(*api.CreateFileOptions)
if ctx.Repo.Repository.IsEmpty {
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
}
if apiOpts.BranchName == "" {
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch