|
|
@@ -8,6 +8,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/routers/response" |
|
|
|
"code.gitea.io/gitea/services/repository" |
|
|
|
techService "code.gitea.io/gitea/services/tech" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
) |
|
|
@@ -86,7 +87,7 @@ func CommitNotOpenIRepo(ctx *context.APIContext, form api.NotOpenITechRepo) { |
|
|
|
RepoName: form.RepoName, |
|
|
|
Alias: form.Alias, |
|
|
|
Description: form.Description, |
|
|
|
Labels: true, |
|
|
|
Labels: false, |
|
|
|
Mirror: true, |
|
|
|
}) |
|
|
|
if bizErr != nil { |
|
|
@@ -115,6 +116,9 @@ func CommitNotOpenIRepo(ctx *context.APIContext, form api.NotOpenITechRepo) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//给仓库加标签 |
|
|
|
updateTopics(repo.ID, form.Topics) |
|
|
|
|
|
|
|
//写入数据库 |
|
|
|
rci := &models.RepoConvergeInfo{ |
|
|
|
RepoID: repo.ID, |
|
|
@@ -131,3 +135,21 @@ func CommitNotOpenIRepo(ctx *context.APIContext, form api.NotOpenITechRepo) { |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, response.OuterSuccess()) |
|
|
|
} |
|
|
|
|
|
|
|
func updateTopics(repoId int64, topicNames []string) error { |
|
|
|
validTopics, invalidTopics := models.SanitizeAndValidateTopics(topicNames) |
|
|
|
|
|
|
|
if len(validTopics) > 25 { |
|
|
|
return errors.New("Exceeding maximum number of topics per repo") |
|
|
|
} |
|
|
|
|
|
|
|
if len(invalidTopics) > 0 { |
|
|
|
return errors.New("Topic names are invalid") |
|
|
|
} |
|
|
|
|
|
|
|
err := models.SaveTopics(repoId, validTopics...) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |