|
|
@@ -177,13 +177,25 @@ func AddTopic(ctx *context.APIContext) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
_, err = models.AddTopic(ctx.Repo.Repository.ID, topicName) |
|
|
|
topic, err := models.AddTopic(ctx.Repo.Repository.ID, topicName) |
|
|
|
if err != nil { |
|
|
|
log.Error("AddTopic failed: %v", err) |
|
|
|
ctx.InternalServerError(err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
found := false |
|
|
|
topicNames := make([]string, len(topics)) |
|
|
|
for i, t := range topics { |
|
|
|
topicNames[i] = t.Name |
|
|
|
if strings.EqualFold(topic.Name, t.Name) { |
|
|
|
found = true |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if !found && topic.Name != "" { |
|
|
|
topicNames = append(topicNames, topic.Name) |
|
|
|
} |
|
|
|
models.UpdateRepoTopics(ctx.Repo.Repository.ID, topicNames) |
|
|
|
ctx.Status(http.StatusNoContent) |
|
|
|
} |
|
|
|
|
|
|
|