mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 01:40:36 +00:00
make branch parameter optional for /api/v1/repos/{owner}/{repo}/contents/{filepath} (#11067)
This commit is contained in:
parent
7179e49881
commit
b9ed8d8497
1 changed files with 12 additions and 0 deletions
|
@ -199,6 +199,10 @@ func CreateFile(ctx *context.APIContext, apiOpts api.CreateFileOptions) {
|
||||||
// "201":
|
// "201":
|
||||||
// "$ref": "#/responses/FileResponse"
|
// "$ref": "#/responses/FileResponse"
|
||||||
|
|
||||||
|
if apiOpts.BranchName == "" {
|
||||||
|
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
|
||||||
|
}
|
||||||
|
|
||||||
opts := &repofiles.UpdateRepoFileOptions{
|
opts := &repofiles.UpdateRepoFileOptions{
|
||||||
Content: apiOpts.Content,
|
Content: apiOpts.Content,
|
||||||
IsNewFile: true,
|
IsNewFile: true,
|
||||||
|
@ -271,6 +275,10 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) {
|
||||||
// "200":
|
// "200":
|
||||||
// "$ref": "#/responses/FileResponse"
|
// "$ref": "#/responses/FileResponse"
|
||||||
|
|
||||||
|
if apiOpts.BranchName == "" {
|
||||||
|
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
|
||||||
|
}
|
||||||
|
|
||||||
opts := &repofiles.UpdateRepoFileOptions{
|
opts := &repofiles.UpdateRepoFileOptions{
|
||||||
Content: apiOpts.Content,
|
Content: apiOpts.Content,
|
||||||
SHA: apiOpts.SHA,
|
SHA: apiOpts.SHA,
|
||||||
|
@ -377,6 +385,10 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if apiOpts.BranchName == "" {
|
||||||
|
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
|
||||||
|
}
|
||||||
|
|
||||||
opts := &repofiles.DeleteRepoFileOptions{
|
opts := &repofiles.DeleteRepoFileOptions{
|
||||||
Message: apiOpts.Message,
|
Message: apiOpts.Message,
|
||||||
OldBranch: apiOpts.BranchName,
|
OldBranch: apiOpts.BranchName,
|
||||||
|
|
Loading…
Reference in a new issue