Skip to content

Commit 1848263

Browse files
Merge branch 'main' into local-makefile-customizations
2 parents c2889d5 + 0ce7d66 commit 1848263

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+330
-641
lines changed

.github/labeler.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ modifies/internal:
5151
- ".github/**"
5252
- ".gitea/**"
5353
- ".devcontainer/**"
54-
- "build.go"
5554
- "build/**"
5655
- "contrib/**"
5756

Makefile

Lines changed: 2 additions & 18 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
@@ -280,19 +279,6 @@ fmt-check: fmt
280279
exit 1; \
281280
fi
282281

283-
.PHONY: fix
284-
fix: ## apply automated fixes to Go code
285-
$(GO) run $(GOPLS_MODERNIZE_PACKAGE) -fix ./...
286-
287-
.PHONY: fix-check
288-
fix-check: fix
289-
@diff=$$(git diff --color=always $(GO_SOURCES)); \
290-
if [ -n "$$diff" ]; then \
291-
echo "Please run 'make fix' and commit the result:"; \
292-
printf "%s" "$${diff}"; \
293-
exit 1; \
294-
fi
295-
296282
.PHONY: $(TAGS_EVIDENCE)
297283
$(TAGS_EVIDENCE):
298284
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -332,7 +318,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
332318
checks-frontend: lockfile-check svg-check ## check frontend files
333319

334320
.PHONY: checks-backend
335-
checks-backend: tidy-check swagger-check fmt-check fix-check swagger-validate security-check ## check backend files
321+
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check ## check backend files
336322

337323
.PHONY: lint
338324
lint: lint-frontend lint-backend lint-spell ## lint everything
@@ -404,8 +390,7 @@ lint-go-windows:
404390
.PHONY: lint-go-gitea-vet
405391
lint-go-gitea-vet: ## lint go files with gitea-vet
406392
@echo "Running gitea-vet..."
407-
@GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
408-
@$(GO) vet -vettool=gitea-vet ./...
393+
@$(GO) vet -vettool="$(shell GOOS= GOARCH= go tool -n gitea-vet)" ./...
409394

410395
.PHONY: lint-go-gopls
411396
lint-go-gopls: ## lint go files with gopls
@@ -856,7 +841,6 @@ deps-tools: ## install tool dependencies
856841
$(GO) install $(GOVULNCHECK_PACKAGE) & \
857842
$(GO) install $(ACTIONLINT_PACKAGE) & \
858843
$(GO) install $(GOPLS_PACKAGE) & \
859-
$(GO) install $(GOPLS_MODERNIZE_PACKAGE) & \
860844
wait
861845

862846
node_modules: pnpm-lock.yaml

build.go

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

flake.lock

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 80 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,94 @@
11
{
22
inputs = {
33
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
4-
flake-utils.url = "github:numtide/flake-utils";
54
};
65
outputs =
7-
{ nixpkgs, flake-utils, ... }:
8-
flake-utils.lib.eachDefaultSystem (
9-
system:
10-
let
11-
pkgs = nixpkgs.legacyPackages.${system};
12-
in
13-
{
14-
devShells.default =
15-
with pkgs;
16-
let
17-
# only bump toolchain versions here
18-
go = go_1_25;
19-
nodejs = nodejs_24;
20-
python3 = python312;
21-
pnpm = pnpm_10;
22-
23-
# Platform-specific dependencies
24-
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [
25-
glibc.static
26-
];
6+
{ nixpkgs, ... }:
7+
let
8+
supportedSystems = [
9+
"aarch64-darwin"
10+
"aarch64-linux"
11+
"x86_64-darwin"
12+
"x86_64-linux"
13+
];
2714

28-
linuxOnlyEnv = lib.optionalAttrs pkgs.stdenv.isLinux {
29-
CFLAGS = "-I${glibc.static.dev}/include";
30-
LDFLAGS = "-L ${glibc.static}/lib";
15+
forEachSupportedSystem =
16+
f:
17+
nixpkgs.lib.genAttrs supportedSystems (
18+
system:
19+
let
20+
pkgs = import nixpkgs {
21+
inherit system;
3122
};
3223
in
33-
pkgs.mkShell (
34-
{
35-
buildInputs = [
36-
# generic
37-
git
38-
git-lfs
39-
gnumake
40-
gnused
41-
gnutar
42-
gzip
43-
zip
24+
f { inherit pkgs; }
25+
);
26+
in
27+
{
28+
devShells = forEachSupportedSystem (
29+
{ pkgs, ... }:
30+
{
31+
default =
32+
let
33+
inherit (pkgs) lib;
34+
35+
# only bump toolchain versions here
36+
go = pkgs.go_1_25;
37+
nodejs = pkgs.nodejs_24;
38+
python3 = pkgs.python312;
39+
pnpm = pkgs.pnpm_10;
4440

45-
# frontend
46-
nodejs
47-
pnpm
48-
cairo
49-
pixman
50-
pkg-config
41+
# Platform-specific dependencies
42+
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [
43+
pkgs.glibc.static
44+
];
5145

52-
# linting
53-
python3
54-
uv
46+
linuxOnlyEnv = lib.optionalAttrs pkgs.stdenv.isLinux {
47+
CFLAGS = "-I${pkgs.glibc.static.dev}/include";
48+
LDFLAGS = "-L ${pkgs.glibc.static}/lib";
49+
};
50+
in
51+
pkgs.mkShell {
52+
packages =
53+
with pkgs;
54+
[
55+
# generic
56+
git
57+
git-lfs
58+
gnumake
59+
gnused
60+
gnutar
61+
gzip
62+
zip
5563

56-
# backend
57-
go
58-
gofumpt
59-
sqlite
60-
]
61-
++ linuxOnlyInputs;
64+
# frontend
65+
nodejs
66+
pnpm
67+
cairo
68+
pixman
69+
pkg-config
6270

63-
GO = "${go}/bin/go";
64-
GOROOT = "${go}/share/go";
71+
# linting
72+
python3
73+
uv
6574

66-
TAGS = "sqlite sqlite_unlock_notify";
67-
STATIC = "true";
68-
}
69-
// linuxOnlyEnv
70-
);
71-
}
72-
);
75+
# backend
76+
go
77+
gofumpt
78+
sqlite
79+
]
80+
++ linuxOnlyInputs;
81+
82+
env = {
83+
GO = "${go}/bin/go";
84+
GOROOT = "${go}/share/go";
85+
86+
TAGS = "sqlite sqlite_unlock_notify";
87+
STATIC = "true";
88+
}
89+
// linuxOnlyEnv;
90+
};
91+
}
92+
);
93+
};
7394
}

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.25.3
3+
go 1.25.4
44

55
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
66
// But some CAs use negative serial number, just relax the check. related:
@@ -9,7 +9,6 @@ godebug x509negativeserial=1
99

1010
require (
1111
code.gitea.io/actions-proto-go v0.4.1
12-
code.gitea.io/gitea-vet v0.2.3
1312
code.gitea.io/sdk/gitea v0.22.0
1413
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
1514
connectrpc.com/connect v1.18.1
@@ -135,6 +134,7 @@ require (
135134

136135
require (
137136
cloud.google.com/go/compute/metadata v0.8.0 // indirect
137+
code.gitea.io/gitea-vet v0.2.3 // indirect
138138
dario.cat/mergo v1.0.2 // indirect
139139
filippo.io/edwards25519 v1.1.0 // indirect
140140
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
@@ -307,3 +307,5 @@ exclude github.com/gofrs/uuid v4.0.0+incompatible
307307
exclude github.com/goccy/go-json v0.4.11
308308

309309
exclude github.com/satori/go.uuid v1.2.0
310+
311+
tool code.gitea.io/gitea-vet

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 {

0 commit comments

Comments
 (0)