mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 08:38:29 +00:00
Fix some slice append usages (#26778)
Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
3507cad6f5
commit
ad43486cd3
|
@ -223,7 +223,7 @@ func loadServiceFrom(rootCfg ConfigProvider) {
|
|||
Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0)
|
||||
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
|
||||
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
|
||||
schemes := make([]string, len(Service.ValidSiteURLSchemes))
|
||||
schemes := make([]string, 0, len(Service.ValidSiteURLSchemes))
|
||||
for _, scheme := range Service.ValidSiteURLSchemes {
|
||||
scheme = strings.ToLower(strings.TrimSpace(scheme))
|
||||
if scheme != "" {
|
||||
|
|
|
@ -326,11 +326,9 @@ func CreatePullRequest(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
labelIDs = make([]int64, len(form.Labels))
|
||||
orgLabelIDs := make([]int64, len(form.Labels))
|
||||
|
||||
for i := range labels {
|
||||
labelIDs[i] = labels[i].ID
|
||||
labelIDs = make([]int64, 0, len(labels))
|
||||
for _, label := range labels {
|
||||
labelIDs = append(labelIDs, label.ID)
|
||||
}
|
||||
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
|
@ -340,13 +338,13 @@ func CreatePullRequest(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
for i := range orgLabels {
|
||||
orgLabelIDs[i] = orgLabels[i].ID
|
||||
orgLabelIDs := make([]int64, 0, len(orgLabels))
|
||||
for _, orgLabel := range orgLabels {
|
||||
orgLabelIDs = append(orgLabelIDs, orgLabel.ID)
|
||||
}
|
||||
}
|
||||
|
||||
labelIDs = append(labelIDs, orgLabelIDs...)
|
||||
}
|
||||
}
|
||||
|
||||
if form.Milestone > 0 {
|
||||
milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, form.Milestone)
|
||||
|
|
|
@ -114,12 +114,12 @@ func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, erro
|
|||
return nil, err
|
||||
}
|
||||
|
||||
filelist := make([]string, len(filenames))
|
||||
fileList := make([]string, 0, len(filenames))
|
||||
for _, line := range bytes.Split(stdOut.Bytes(), []byte{'\000'}) {
|
||||
filelist = append(filelist, string(line))
|
||||
fileList = append(fileList, string(line))
|
||||
}
|
||||
|
||||
return filelist, nil
|
||||
return fileList, nil
|
||||
}
|
||||
|
||||
// RemoveFilesFromIndex removes the given files from the index
|
||||
|
|
Loading…
Reference in a new issue