diff options
author | 6543 <6543@obermui.de> | 2020-04-20 18:47:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 17:47:05 +0100 |
commit | b9ed8d849770fcb977f946d9708d137c04f43a40 (patch) | |
tree | eae689b5cf0afbc578630c06f59d6872d50297d8 /routers | |
parent | 7179e498815bcfc0eaa81dc08c499be6ddc3dc2f (diff) | |
download | gitea-b9ed8d849770fcb977f946d9708d137c04f43a40.tar.gz gitea-b9ed8d849770fcb977f946d9708d137c04f43a40.zip |
make branch parameter optional for /api/v1/repos/{owner}/{repo}/contents/{filepath} (#11067)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/file.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 90a84cd54c..d409a28489 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -199,6 +199,10 @@ func CreateFile(ctx *context.APIContext, apiOpts api.CreateFileOptions) { // "201": // "$ref": "#/responses/FileResponse" + if apiOpts.BranchName == "" { + apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch + } + opts := &repofiles.UpdateRepoFileOptions{ Content: apiOpts.Content, IsNewFile: true, @@ -271,6 +275,10 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) { // "200": // "$ref": "#/responses/FileResponse" + if apiOpts.BranchName == "" { + apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch + } + opts := &repofiles.UpdateRepoFileOptions{ Content: apiOpts.Content, SHA: apiOpts.SHA, @@ -377,6 +385,10 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) { return } + if apiOpts.BranchName == "" { + apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch + } + opts := &repofiles.DeleteRepoFileOptions{ Message: apiOpts.Message, OldBranch: apiOpts.BranchName, |