@@ -140,7 +140,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
140140
141141// InitRepository initializes README and .gitignore if needed.
142142func initRepository (ctx context.Context , repoPath string , u * user_model.User , repo * repo_model.Repository , opts CreateRepoOptions ) (err error ) {
143- if err = repo_module .CheckInitRepository (ctx , repo . OwnerName , repo . Name , opts . ObjectFormatName ); err != nil {
143+ if err = repo_module .CheckInitRepository (ctx , repo ); err != nil {
144144 return err
145145 }
146146
@@ -256,10 +256,9 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
256256 return nil
257257 }
258258
259- repoPath := repo_model .RepoPath (u .Name , repo .Name )
260- isExist , err := util .IsExist (repoPath )
259+ isExist , err := gitrepo .IsRepositoryExist (ctx , repo )
261260 if err != nil {
262- log .Error ("Unable to check if %s exists. Error: %v" , repoPath , err )
261+ log .Error ("Unable to check if %s exists. Error: %v" , repo . RepoPath () , err )
263262 return err
264263 }
265264 if isExist {
@@ -270,15 +269,15 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
270269 //
271270 // Previously Gitea would just delete and start afresh - this was naughty.
272271 // So we will now fail and delegate to other functionality to adopt or delete
273- log .Error ("Files already exist in %s and we are not going to adopt or delete." , repoPath )
272+ log .Error ("Files already exist in %s and we are not going to adopt or delete." , repo . RepoPath () )
274273 return repo_model.ErrRepoFilesAlreadyExist {
275274 Uname : u .Name ,
276275 Name : repo .Name ,
277276 }
278277 }
279278
280- if err = initRepository (ctx , repoPath , doer , repo , opts ); err != nil {
281- if err2 := util .RemoveAll (repoPath ); err2 != nil {
279+ if err = initRepository (ctx , repo . RepoPath () , doer , repo , opts ); err != nil {
280+ if err2 := util .RemoveAll (repo . RepoPath () ); err2 != nil {
282281 log .Error ("initRepository: %v" , err )
283282 return fmt .Errorf (
284283 "delete repo directory %s/%s failed(2): %v" , u .Name , repo .Name , err2 )
@@ -300,7 +299,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
300299 }
301300
302301 if stdout , _ , err := git .NewCommand ("update-server-info" ).
303- RunStdString (ctx , & git.RunOpts {Dir : repoPath }); err != nil {
302+ RunStdString (ctx , & git.RunOpts {Dir : repo . RepoPath () }); err != nil {
304303 log .Error ("CreateRepository(git update-server-info) in %v: Stdout: %s\n Error: %v" , repo , stdout , err )
305304 rollbackRepo = repo
306305 rollbackRepo .OwnerID = u .ID
@@ -312,7 +311,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
312311 if len (opts .License ) > 0 {
313312 licenses = append (licenses , opts .License )
314313
315- stdout , _ , err := git .NewCommand ("rev-parse" , "HEAD" ).RunStdString (ctx , & git.RunOpts {Dir : repoPath })
314+ stdout , _ , err := git .NewCommand ("rev-parse" , "HEAD" ).RunStdString (ctx , & git.RunOpts {Dir : repo . RepoPath () })
316315 if err != nil {
317316 log .Error ("CreateRepository(git rev-parse HEAD) in %v: Stdout: %s\n Error: %v" , repo , stdout , err )
318317 rollbackRepo = repo
@@ -353,14 +352,13 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re
353352 }
354353 }
355354
356- repoPath := repo_model .RepoPath (u .Name , repo .Name )
357- isExist , err := util .IsExist (repoPath )
355+ isExist , err := gitrepo .IsRepositoryExist (ctx , repo )
358356 if err != nil {
359- log .Error ("Unable to check if %s exists. Error: %v" , repoPath , err )
357+ log .Error ("Unable to check if %s exists. Error: %v" , repo . RepoPath () , err )
360358 return err
361359 }
362360 if ! overwriteOrAdopt && isExist {
363- log .Error ("Files already exist in %s and we are not going to adopt or delete." , repoPath )
361+ log .Error ("Files already exist in %s and we are not going to adopt or delete." , repo . RepoPath () )
364362 return repo_model.ErrRepoFilesAlreadyExist {
365363 Uname : u .Name ,
366364 Name : repo .Name ,
0 commit comments