@ -726,12 +726,9 @@ func GetRepositoriesMapByIDs(ids []int64) (map[int64]*Repository, error) {
return repos , db . GetEngine ( db . DefaultContext ) . In ( "id" , ids ) . Find ( & repos )
return repos , db . GetEngine ( db . DefaultContext ) . In ( "id" , ids ) . Find ( & repos )
}
}
// IsRepositoryExist returns true if the repository with given name under user has already existed.
// IsRepositoryModelOrDirExist returns true if the repository with given name under user has already existed.
func IsRepositoryExist ( ctx context . Context , u * user_model . User , repoName string ) ( bool , error ) {
func IsRepositoryModelOrDirExist ( ctx context . Context , u * user_model . User , repoName string ) ( bool , error ) {
has , err := db . GetEngine ( ctx ) . Get ( & Repository {
has , err := IsRepositoryModelExist ( ctx , u , repoName )
OwnerID : u . ID ,
LowerName : strings . ToLower ( repoName ) ,
} )
if err != nil {
if err != nil {
return false , err
return false , err
}
}
@ -739,6 +736,13 @@ func IsRepositoryExist(ctx context.Context, u *user_model.User, repoName string)
return has || isDir , err
return has || isDir , err
}
}
func IsRepositoryModelExist ( ctx context . Context , u * user_model . User , repoName string ) ( bool , error ) {
return db . GetEngine ( ctx ) . Get ( & Repository {
OwnerID : u . ID ,
LowerName : strings . ToLower ( repoName ) ,
} )
}
// GetTemplateRepo populates repo.TemplateRepo for a generated repository and
// GetTemplateRepo populates repo.TemplateRepo for a generated repository and
// returns an error on failure (NOTE: no error is returned for
// returns an error on failure (NOTE: no error is returned for
// non-generated repositories, and TemplateRepo will be left untouched)
// non-generated repositories, and TemplateRepo will be left untouched)