@@ -12,16 +12,16 @@ import (
1212
1313 "code.gitea.io/gitea/models"
1414 "code.gitea.io/gitea/modules/git"
15- "code.gitea.io/gitea/modules/repofiles"
1615 "code.gitea.io/gitea/modules/setting"
1716 api "code.gitea.io/gitea/modules/structs"
1817 "code.gitea.io/gitea/modules/test"
18+ files_service "code.gitea.io/gitea/services/repository/files"
1919
2020 "github.com/stretchr/testify/assert"
2121)
2222
23- func getCreateRepoFileOptions (repo * models.Repository ) * repofiles .UpdateRepoFileOptions {
24- return & repofiles .UpdateRepoFileOptions {
23+ func getCreateRepoFileOptions (repo * models.Repository ) * files_service .UpdateRepoFileOptions {
24+ return & files_service .UpdateRepoFileOptions {
2525 OldBranch : repo .DefaultBranch ,
2626 NewBranch : repo .DefaultBranch ,
2727 TreePath : "new/file.txt" ,
@@ -33,8 +33,8 @@ func getCreateRepoFileOptions(repo *models.Repository) *repofiles.UpdateRepoFile
3333 }
3434}
3535
36- func getUpdateRepoFileOptions (repo * models.Repository ) * repofiles .UpdateRepoFileOptions {
37- return & repofiles .UpdateRepoFileOptions {
36+ func getUpdateRepoFileOptions (repo * models.Repository ) * files_service .UpdateRepoFileOptions {
37+ return & files_service .UpdateRepoFileOptions {
3838 OldBranch : repo .DefaultBranch ,
3939 NewBranch : repo .DefaultBranch ,
4040 TreePath : "README.md" ,
@@ -198,7 +198,7 @@ func TestCreateOrUpdateRepoFileForCreate(t *testing.T) {
198198 opts := getCreateRepoFileOptions (repo )
199199
200200 // test
201- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
201+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
202202
203203 // asserts
204204 assert .NoError (t , err )
@@ -234,7 +234,7 @@ func TestCreateOrUpdateRepoFileForUpdate(t *testing.T) {
234234 opts := getUpdateRepoFileOptions (repo )
235235
236236 // test
237- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
237+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
238238
239239 // asserts
240240 assert .NoError (t , err )
@@ -269,7 +269,7 @@ func TestCreateOrUpdateRepoFileForUpdateWithFileMove(t *testing.T) {
269269 opts .TreePath = "README_new.md" // new file name, README_new.md
270270
271271 // test
272- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
272+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
273273
274274 // asserts
275275 assert .NoError (t , err )
@@ -319,7 +319,7 @@ func TestCreateOrUpdateRepoFileWithoutBranchNames(t *testing.T) {
319319 opts .NewBranch = ""
320320
321321 // test
322- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
322+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
323323
324324 // asserts
325325 assert .NoError (t , err )
@@ -349,7 +349,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
349349 t .Run ("bad branch" , func (t * testing.T ) {
350350 opts := getUpdateRepoFileOptions (repo )
351351 opts .OldBranch = "bad_branch"
352- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
352+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
353353 assert .Error (t , err )
354354 assert .Nil (t , fileResponse )
355355 expectedError := "branch does not exist [name: " + opts .OldBranch + "]"
@@ -360,7 +360,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
360360 opts := getUpdateRepoFileOptions (repo )
361361 origSHA := opts .SHA
362362 opts .SHA = "bad_sha"
363- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
363+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
364364 assert .Nil (t , fileResponse )
365365 assert .Error (t , err )
366366 expectedError := "sha does not match [given: " + opts .SHA + ", expected: " + origSHA + "]"
@@ -370,7 +370,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
370370 t .Run ("new branch already exists" , func (t * testing.T ) {
371371 opts := getUpdateRepoFileOptions (repo )
372372 opts .NewBranch = "develop"
373- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
373+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
374374 assert .Nil (t , fileResponse )
375375 assert .Error (t , err )
376376 expectedError := "branch already exists [name: " + opts .NewBranch + "]"
@@ -380,7 +380,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
380380 t .Run ("treePath is empty:" , func (t * testing.T ) {
381381 opts := getUpdateRepoFileOptions (repo )
382382 opts .TreePath = ""
383- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
383+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
384384 assert .Nil (t , fileResponse )
385385 assert .Error (t , err )
386386 expectedError := "path contains a malformed path component [path: ]"
@@ -390,7 +390,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
390390 t .Run ("treePath is a git directory:" , func (t * testing.T ) {
391391 opts := getUpdateRepoFileOptions (repo )
392392 opts .TreePath = ".git"
393- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
393+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
394394 assert .Nil (t , fileResponse )
395395 assert .Error (t , err )
396396 expectedError := "path contains a malformed path component [path: " + opts .TreePath + "]"
@@ -400,7 +400,7 @@ func TestCreateOrUpdateRepoFileErrors(t *testing.T) {
400400 t .Run ("create file that already exists" , func (t * testing.T ) {
401401 opts := getCreateRepoFileOptions (repo )
402402 opts .TreePath = "README.md" //already exists
403- fileResponse , err := repofiles .CreateOrUpdateRepoFile (repo , doer , opts )
403+ fileResponse , err := files_service .CreateOrUpdateRepoFile (repo , doer , opts )
404404 assert .Nil (t , fileResponse )
405405 assert .Error (t , err )
406406 expectedError := "repository file already exists [path: " + opts .TreePath + "]"
0 commit comments