Skip to content

Commit e932d2d

Browse files
authored
Merge branch 'main' into labelpad
2 parents 0db2d49 + 61e5cc1 commit e932d2d

27 files changed

+198
-469
lines changed

Makefile

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
4141
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
4242
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
4343
GOPLS_PACKAGE ?= golang.org/x/tools/[email protected]
44-
GOPLS_MODERNIZE_PACKAGE ?= golang.org/x/tools/gopls/internal/analysis/modernize/cmd/[email protected]
4544

4645
DOCKER_IMAGE ?= gitea/gitea
4746
DOCKER_TAG ?= latest
@@ -276,19 +275,6 @@ fmt-check: fmt
276275
exit 1; \
277276
fi
278277

279-
.PHONY: fix
280-
fix: ## apply automated fixes to Go code
281-
$(GO) run $(GOPLS_MODERNIZE_PACKAGE) -fix ./...
282-
283-
.PHONY: fix-check
284-
fix-check: fix
285-
@diff=$$(git diff --color=always $(GO_SOURCES)); \
286-
if [ -n "$$diff" ]; then \
287-
echo "Please run 'make fix' and commit the result:"; \
288-
printf "%s" "$${diff}"; \
289-
exit 1; \
290-
fi
291-
292278
.PHONY: $(TAGS_EVIDENCE)
293279
$(TAGS_EVIDENCE):
294280
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -328,7 +314,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
328314
checks-frontend: lockfile-check svg-check ## check frontend files
329315

330316
.PHONY: checks-backend
331-
checks-backend: tidy-check swagger-check fmt-check fix-check swagger-validate security-check ## check backend files
317+
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check ## check backend files
332318

333319
.PHONY: lint
334320
lint: lint-frontend lint-backend lint-spell ## lint everything
@@ -852,7 +838,6 @@ deps-tools: ## install tool dependencies
852838
$(GO) install $(GOVULNCHECK_PACKAGE) & \
853839
$(GO) install $(ACTIONLINT_PACKAGE) & \
854840
$(GO) install $(GOPLS_PACKAGE) & \
855-
$(GO) install $(GOPLS_MODERNIZE_PACKAGE) & \
856841
wait
857842

858843
node_modules: pnpm-lock.yaml

modules/base/natural_sort.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func naturalSortAdvance(str string, pos int) (end int, isNumber bool) {
4141
return end, isNumber
4242
}
4343

44-
// NaturalSortLess compares two strings so that they could be sorted in natural order
45-
func NaturalSortLess(s1, s2 string) bool {
44+
// NaturalSortCompare compares two strings so that they could be sorted in natural order
45+
func NaturalSortCompare(s1, s2 string) int {
4646
// There is a bug in Golang's collate package: https://github.com/golang/go/issues/67997
4747
// text/collate: CompareString(collate.Numeric) returns wrong result for "0.0" vs "1.0" #67997
4848
// So we need to handle the number parts by ourselves
@@ -55,16 +55,16 @@ func NaturalSortLess(s1, s2 string) bool {
5555
if isNum1 && isNum2 {
5656
if part1 != part2 {
5757
if len(part1) != len(part2) {
58-
return len(part1) < len(part2)
58+
return len(part1) - len(part2)
5959
}
60-
return part1 < part2
60+
return c.CompareString(part1, part2)
6161
}
6262
} else {
6363
if cmp := c.CompareString(part1, part2); cmp != 0 {
64-
return cmp < 0
64+
return cmp
6565
}
6666
}
6767
pos1, pos2 = end1, end2
6868
}
69-
return len(s1) < len(s2)
69+
return len(s1) - len(s2)
7070
}

modules/base/natural_sort_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import (
1111

1212
func TestNaturalSortLess(t *testing.T) {
1313
testLess := func(s1, s2 string) {
14-
assert.True(t, NaturalSortLess(s1, s2), "s1<s2 should be true: s1=%q, s2=%q", s1, s2)
15-
assert.False(t, NaturalSortLess(s2, s1), "s2<s1 should be false: s1=%q, s2=%q", s1, s2)
14+
assert.Negative(t, NaturalSortCompare(s1, s2), "s1<s2 should be true: s1=%q, s2=%q", s1, s2)
1615
}
1716
testEqual := func(s1, s2 string) {
18-
assert.False(t, NaturalSortLess(s1, s2), "s1<s2 should be false: s1=%q, s2=%q", s1, s2)
19-
assert.False(t, NaturalSortLess(s2, s1), "s2<s1 should be false: s1=%q, s2=%q", s1, s2)
17+
assert.Zero(t, NaturalSortCompare(s1, s2), "s1<s2 should be false: s1=%q, s2=%q", s1, s2)
2018
}
2119

2220
testEqual("", "")

modules/git/commit_info_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) {
173173
} else if entries, err = commit.Tree.ListEntries(); err != nil {
174174
b.Fatal(err)
175175
}
176-
entries.Sort()
177176
b.ResetTimer()
178177
b.Run(benchmark.name, func(b *testing.B) {
179178
for b.Loop() {

modules/git/notes_gogit.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package git
77

88
import (
99
"context"
10+
"fmt"
1011
"io"
1112

1213
"code.gitea.io/gitea/modules/log"
@@ -30,7 +31,11 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
3031

3132
remainingCommitID := commitID
3233
path := ""
33-
currentTree := notes.Tree.gogitTree
34+
currentTree, err := notes.Tree.gogitTreeObject()
35+
if err != nil {
36+
return fmt.Errorf("unable to get tree object for notes commit %q: %w", notes.ID.String(), err)
37+
}
38+
3439
log.Trace("Found tree with ID %q while searching for git note corresponding to the commit %q", currentTree.Entries[0].Name, commitID)
3540
var file *object.File
3641
for len(remainingCommitID) > 2 {

modules/git/parse_gogit.go

Lines changed: 0 additions & 96 deletions
This file was deleted.

modules/git/parse_gogit_test.go

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2018 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//go:build !gogit
5-
64
package git
75

86
import (
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2021 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//go:build !gogit
5-
64
package git
75

86
import (

modules/git/repo_commit_gogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (repo *Repository) getCommit(id ObjectID) (*Commit, error) {
107107
}
108108

109109
commit.Tree.ID = ParseGogitHash(tree.Hash)
110-
commit.Tree.gogitTree = tree
110+
commit.Tree.resolvedGogitTreeObject = tree
111111

112112
return commit, nil
113113
}

0 commit comments

Comments
 (0)