@ -231,6 +231,22 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre
if opt . AutoInit && opt . Readme == "" {
if opt . AutoInit && opt . Readme == "" {
opt . Readme = "Default"
opt . Readme = "Default"
}
}
contains := func ( slice [ ] string , s string ) bool {
for _ , v := range slice {
if v == s {
return true
}
}
return false
}
// If the readme template does not exist, a 400 will be returned.
if opt . AutoInit && len ( opt . Readme ) > 0 && ! contains ( repo_module . Readmes , opt . Readme ) {
ctx . Error ( http . StatusBadRequest , "" , fmt . Errorf ( "readme template does not exist, available templates: %v" , repo_module . Readmes ) )
return
}
repo , err := repo_service . CreateRepository ( ctx . Doer , owner , repo_module . CreateRepoOptions {
repo , err := repo_service . CreateRepository ( ctx . Doer , owner , repo_module . CreateRepoOptions {
Name : opt . Name ,
Name : opt . Name ,
Description : opt . Description ,
Description : opt . Description ,
@ -283,6 +299,8 @@ func Create(ctx *context.APIContext) {
// responses:
// responses:
// "201":
// "201":
// "$ref": "#/responses/Repository"
// "$ref": "#/responses/Repository"
// "400":
// "$ref": "#/responses/error"
// "409":
// "409":
// description: The repository with the same name already exists.
// description: The repository with the same name already exists.
// "422":
// "422":
@ -464,6 +482,8 @@ func CreateOrgRepo(ctx *context.APIContext) {
// responses:
// responses:
// "201":
// "201":
// "$ref": "#/responses/Repository"
// "$ref": "#/responses/Repository"
// "400":
// "$ref": "#/responses/error"
// "404":
// "404":
// "$ref": "#/responses/notFound"
// "$ref": "#/responses/notFound"
// "403":
// "403":