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

Make branch parameter optional for /api/v1/repos/{owner}/{repo}/contents/{filepath} #11067

Merged
merged 14 commits into from
Apr 20, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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