Skip to content

Commit

Permalink
make branch parameter optional for /api/v1/repos/{owner}/{repo}/conte…
Browse files Browse the repository at this point in the history
…nts/{filepath} (go-gitea#11067)
  • Loading branch information
6543 authored and Yohann Delafollye committed Jul 31, 2020
1 parent ad56744 commit d1d1f9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions routers/api/v1/repo/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d1d1f9a

Please sign in to comment.