@@ -199,7 +199,10 @@ func initRepository(ctx context.Context, u *user_model.User, repo *repo_model.Re
199199}
200200
201201// CreateRepositoryDirectly creates a repository for the user/organization.
202- func CreateRepositoryDirectly (ctx context.Context , doer , owner * user_model.User , opts CreateRepoOptions ) (* repo_model.Repository , error ) {
202+ // if needsUpdateToReady is true, it will update the repository status to ready when success
203+ func CreateRepositoryDirectly (ctx context.Context , doer , owner * user_model.User ,
204+ opts CreateRepoOptions , needsUpdateToReady bool ,
205+ ) (* repo_model.Repository , error ) {
203206 if ! doer .CanCreateRepoIn (owner ) {
204207 return nil , repo_model.ErrReachLimitOfRepo {
205208 Limit : owner .MaxRepoCreation ,
@@ -243,8 +246,6 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
243246 ObjectFormatName : opts .ObjectFormatName ,
244247 }
245248
246- needsUpdateStatus := opts .Status != repo_model .RepositoryReady
247-
248249 // 1 - create the repository database operations first
249250 err := db .WithTx (ctx , func (ctx context.Context ) error {
250251 return createRepositoryInDB (ctx , doer , owner , repo , false )
@@ -318,7 +319,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
318319 }
319320
320321 // 7 - update repository status to be ready
321- if needsUpdateStatus {
322+ if needsUpdateToReady {
322323 repo .Status = repo_model .RepositoryReady
323324 if err = repo_model .UpdateRepositoryCols (ctx , repo , "status" ); err != nil {
324325 return nil , fmt .Errorf ("UpdateRepositoryCols: %w" , err )
0 commit comments