mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
Fix lint
This commit is contained in:
parent
80fa6056af
commit
0ce544bc40
10 changed files with 23 additions and 25 deletions
|
|
@ -114,8 +114,7 @@ func RecreateTables(beans ...any) func(*xorm.Engine) error {
|
|||
// Drop all the old tables in the right order, starting with satellite tables working inwards to base tables,
|
||||
// and rename all the temp tables to the final tables. The database will automatically update the foreign key
|
||||
// references during the rename from temp to final tables.
|
||||
for i := len(orderedBeans) - 1; i >= 0; i-- {
|
||||
bean := orderedBeans[i]
|
||||
for _, bean := range slices.Backward(orderedBeans) {
|
||||
log.Info("Dropping existing table %s, and renaming temp table %s in its place", tableNames[bean], tempTableNames[bean])
|
||||
if err := renameTable(sess, bean, tableNames[bean], tempTableNames[bean], tableSchemas[bean]); err != nil {
|
||||
// renameTable does its own logging
|
||||
|
|
|
|||
|
|
@ -211,8 +211,7 @@ func (l *loader) Load() error {
|
|||
tableDeleted := make(container.Set[string])
|
||||
|
||||
// Issue deletes first, in reverse of insertion order, to maintain foreign key constraints.
|
||||
for i := len(l.fixtureFiles) - 1; i >= 0; i-- {
|
||||
fixture := l.fixtureFiles[i]
|
||||
for _, fixture := range slices.Backward(l.fixtureFiles) {
|
||||
if !tableDeleted.Contains(fixture.name) {
|
||||
if _, err := tx.Exec(fmt.Sprintf("DELETE FROM %s", l.quoteKeyword(fixture.name))); err != nil {
|
||||
return fmt.Errorf("cannot delete table %s: %w", fixture.name, err)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -964,9 +965,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
|
|||
var prevCommit, curCommit, nextCommit *git.Commit
|
||||
|
||||
// Iterate in reverse to properly map "previous" and "next" buttons
|
||||
for i := len(prInfo.Commits) - 1; i >= 0; i-- {
|
||||
commit := prInfo.Commits[i]
|
||||
|
||||
for _, commit := range slices.Backward(prInfo.Commits) {
|
||||
if curCommit != nil {
|
||||
nextCommit = commit
|
||||
break
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
package gitdiff
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"forgejo.org/modules/highlight"
|
||||
|
|
@ -214,8 +215,7 @@ func (hcd *HighlightCodeDiff) Recover(src string) string {
|
|||
|
||||
if len(tagStack) > 0 {
|
||||
// close all opening tags
|
||||
for i := len(tagStack) - 1; i >= 0; i-- {
|
||||
tagToClose := tagStack[i]
|
||||
for _, tagToClose := range slices.Backward(tagStack) {
|
||||
// get the closing tag "</span>" from "<span class=...>" or "<span>"
|
||||
pos := strings.IndexAny(tagToClose, " >")
|
||||
if pos != -1 {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"html"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -104,9 +105,7 @@ func getIssueFromRef(ctx context.Context, repo *repo_model.Repository, index int
|
|||
// UpdateIssuesCommit checks if issues are manipulated by commit message.
|
||||
func UpdateIssuesCommit(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, commits []*repository.PushCommit, branchName string) error {
|
||||
// Commits are appended in the reverse order.
|
||||
for i := len(commits) - 1; i >= 0; i-- {
|
||||
c := commits[i]
|
||||
|
||||
for _, c := range slices.Backward(commits) {
|
||||
type markKey struct {
|
||||
ID int64
|
||||
Action references.XRefAction
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package pull
|
|||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
|
||||
issues_model "forgejo.org/models/issues"
|
||||
repo_model "forgejo.org/models/repo"
|
||||
|
|
@ -53,8 +54,8 @@ func getCommitIDsFromRepo(ctx context.Context, repo *repo_model.Repository, oldC
|
|||
}
|
||||
|
||||
commitIDs = make([]string, 0, len(commits))
|
||||
for i := len(commits) - 1; i >= 0; i-- {
|
||||
commitIDs = append(commitIDs, commits[i].ID.String())
|
||||
for _, v := range slices.Backward(commits) {
|
||||
commitIDs = append(commitIDs, v.ID.String())
|
||||
}
|
||||
|
||||
return commitIDs, isForcePush, err
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -101,8 +102,8 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
|
|||
|
||||
data := issues_model.PushActionContent{IsForcePush: false}
|
||||
data.CommitIDs = make([]string, 0, len(compareInfo.Commits))
|
||||
for i := len(compareInfo.Commits) - 1; i >= 0; i-- {
|
||||
data.CommitIDs = append(data.CommitIDs, compareInfo.Commits[i].ID.String())
|
||||
for _, v := range slices.Backward(compareInfo.Commits) {
|
||||
data.CommitIDs = append(data.CommitIDs, v.ID.String())
|
||||
}
|
||||
|
||||
dataJSON, err := json.Marshal(data)
|
||||
|
|
@ -665,9 +666,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
|
|||
|
||||
// commits list is in reverse chronological order
|
||||
first := true
|
||||
for i := len(commits) - 1; i >= 0; i-- {
|
||||
commit := commits[i]
|
||||
|
||||
for _, commit := range slices.Backward(commits) {
|
||||
if setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages {
|
||||
maxSize := setting.Repository.PullRequest.DefaultMergeMessageSize
|
||||
if maxSize < 0 || stringBuilder.Len() < maxSize {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package gitgraph
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// Parser represents a git graph parser. It is stateful containing the previous
|
||||
|
|
@ -166,8 +167,7 @@ func (parser *Parser) ParseGlyphs(glyphs []byte) {
|
|||
// release unused colors
|
||||
parser.releaseUnusedColors()
|
||||
|
||||
for i := len(glyphs) - 1; i >= 0; i-- {
|
||||
glyph := glyphs[i]
|
||||
for i, glyph := range slices.Backward(glyphs) {
|
||||
switch glyph {
|
||||
case '|':
|
||||
fallthrough
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -64,8 +65,8 @@ func (e *quotaEnv) APIPathForRepo(uriFormat string, a ...any) string {
|
|||
}
|
||||
|
||||
func (e *quotaEnv) Cleanup() {
|
||||
for i := len(e.cleanups) - 1; i >= 0; i-- {
|
||||
e.cleanups[i]()
|
||||
for _, v := range slices.Backward(e.cleanups) {
|
||||
v()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -1006,8 +1007,8 @@ func (cas convertAs) AsString() string {
|
|||
}
|
||||
|
||||
func (env *quotaWebEnv) Cleanup() {
|
||||
for i := len(env.cleaners) - 1; i >= 0; i-- {
|
||||
env.cleaners[i]()
|
||||
for _, v := range slices.Backward(env.cleaners) {
|
||||
v()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue