forked from forgejo/forgejo
API endpoint for changing/creating/deleting multiple files (#24887)
This PR creates an API endpoint for creating/updating/deleting multiple files in one API call similar to the solution provided by [GitLab](https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions). To archive this, the CreateOrUpdateRepoFile and DeleteRepoFIle functions in files service are unified into one function supporting multiple files and actions. Resolves #14619
This commit is contained in:
parent
245f2c08db
commit
275d4b7e3f
16 changed files with 1309 additions and 778 deletions
|
@ -101,11 +101,15 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod
|
|||
assert.NotEmpty(t, headRepo)
|
||||
|
||||
// create a commit on base Repo
|
||||
_, err = files_service.CreateOrUpdateRepoFile(git.DefaultContext, baseRepo, actor, &files_service.UpdateRepoFileOptions{
|
||||
TreePath: "File_A",
|
||||
_, err = files_service.ChangeRepoFiles(git.DefaultContext, baseRepo, actor, &files_service.ChangeRepoFilesOptions{
|
||||
Files: []*files_service.ChangeRepoFile{
|
||||
{
|
||||
Operation: "create",
|
||||
TreePath: "File_A",
|
||||
Content: "File A",
|
||||
},
|
||||
},
|
||||
Message: "Add File A",
|
||||
Content: "File A",
|
||||
IsNewFile: true,
|
||||
OldBranch: "master",
|
||||
NewBranch: "master",
|
||||
Author: &files_service.IdentityOptions{
|
||||
|
@ -124,11 +128,15 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod
|
|||
assert.NoError(t, err)
|
||||
|
||||
// create a commit on head Repo
|
||||
_, err = files_service.CreateOrUpdateRepoFile(git.DefaultContext, headRepo, actor, &files_service.UpdateRepoFileOptions{
|
||||
TreePath: "File_B",
|
||||
_, err = files_service.ChangeRepoFiles(git.DefaultContext, headRepo, actor, &files_service.ChangeRepoFilesOptions{
|
||||
Files: []*files_service.ChangeRepoFile{
|
||||
{
|
||||
Operation: "create",
|
||||
TreePath: "File_B",
|
||||
Content: "File B",
|
||||
},
|
||||
},
|
||||
Message: "Add File on PR branch",
|
||||
Content: "File B",
|
||||
IsNewFile: true,
|
||||
OldBranch: "master",
|
||||
NewBranch: "newBranch",
|
||||
Author: &files_service.IdentityOptions{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue