Skip to content

Commit 92fbc59

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Remove padding override on `.ui .sha.label` (go-gitea#35864) fix(api/repo/contents): set the dates to now when not specified by the caller (go-gitea#35861) Remove `fix` Make targets (go-gitea#35868) Refactor ls-tree and git path related problems (go-gitea#35858) Fix pull description code label background (go-gitea#35865) Make ACME email optional (go-gitea#35849) Remove wrong code (go-gitea#35846) Fix Arch repo pacman.conf snippet (go-gitea#35825) Port away from `flake-utils` (go-gitea#35675) Update golangci-lint to v2.6.0 (go-gitea#35801) Add a doctor command to fix inconsistent run status (go-gitea#35840) Fix viewed files number is not right if not all files loaded (go-gitea#35821) Fix incorrect pull request counter (go-gitea#35819) Fix a number of `strictNullChecks`-related issues (go-gitea#35795) ignore .worktrees as a "special folder" (go-gitea#35835) upgrade go mail to 0.7.2 and fix the bug (go-gitea#35833)
2 parents df5ab5b + 23a37b4 commit 92fbc59

Some content is hidden

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

75 files changed

+761
-631
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ prime/
124124
/AGENT.md
125125
/CLAUDE.md
126126
/llms.txt
127+
128+
# Ignore worktrees when working on multiple branches
129+
.worktrees/

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ linters:
1414
- govet
1515
- ineffassign
1616
- mirror
17+
- modernize
1718
- nakedret
1819
- nolintlint
1920
- perfsprint
@@ -55,6 +56,7 @@ linters:
5556
disabled-checks:
5657
- ifElseChain
5758
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
59+
- deprecatedComment # conflicts with go-swagger comments
5860
revive:
5961
severity: error
6062
rules:
@@ -107,6 +109,11 @@ linters:
107109
- require-error
108110
usetesting:
109111
os-temp-dir: true
112+
modernize:
113+
disable:
114+
- stringsbuilder
115+
perfsprint:
116+
concat-loop: false
110117
exclusions:
111118
generated: lax
112119
presets:

Makefile

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ XGO_VERSION := go-1.25.x
3232
AIR_PACKAGE ?= github.com/air-verse/air@v1
3333
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
3434
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
35-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0
35+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
3636
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3737
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3838
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
@@ -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

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ require (
109109
github.com/ulikunitz/xz v0.5.15
110110
github.com/urfave/cli-docs/v3 v3.0.0-alpha6
111111
github.com/urfave/cli/v3 v3.4.1
112-
github.com/wneessen/go-mail v0.7.0
112+
github.com/wneessen/go-mail v0.7.2
113113
github.com/xeipuuv/gojsonschema v1.2.0
114114
github.com/yohcop/openid-go v1.0.1
115115
github.com/yuin/goldmark v1.7.13

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,8 @@ github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZ
768768
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
769769
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
770770
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
771-
github.com/wneessen/go-mail v0.7.0 h1:/Wmgd5AVjp5PA+Ken5EFfr+QR83gmqHli9HcAhh0vnU=
772-
github.com/wneessen/go-mail v0.7.0/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
771+
github.com/wneessen/go-mail v0.7.2 h1:xxPnhZ6IZLSgxShebmZ6DPKh1b6OJcoHfzy7UjOkzS8=
772+
github.com/wneessen/go-mail v0.7.2/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
773773
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
774774
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
775775
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=

models/actions/main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ func TestMain(m *testing.M) {
1313
unittest.MainTest(m, &unittest.TestOptions{
1414
FixtureFiles: []string{
1515
"action_runner_token.yml",
16+
"action_run.yml",
17+
"repository.yml",
1618
},
1719
})
1820
}

models/actions/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ func (run *ActionRun) IsSchedule() bool {
193193
return run.ScheduleID > 0
194194
}
195195

196+
// UpdateRepoRunsNumbers updates the number of runs and closed runs of a repository.
196197
func UpdateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
197198
_, err := db.GetEngine(ctx).ID(repo.ID).
198199
NoAutoTime().
200+
Cols("num_action_runs", "num_closed_action_runs").
199201
SetExpr("num_action_runs",
200202
builder.Select("count(*)").From("action_run").
201203
Where(builder.Eq{"repo_id": repo.ID}),

models/actions/run_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package actions
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/db"
10+
repo_model "code.gitea.io/gitea/models/repo"
11+
"code.gitea.io/gitea/models/unittest"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestUpdateRepoRunsNumbers(t *testing.T) {
17+
assert.NoError(t, unittest.PrepareTestDatabase())
18+
19+
// update the number to a wrong one, the original is 3
20+
_, err := db.GetEngine(t.Context()).ID(4).Cols("num_closed_action_runs").Update(&repo_model.Repository{
21+
NumClosedActionRuns: 2,
22+
})
23+
assert.NoError(t, err)
24+
25+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
26+
assert.Equal(t, 4, repo.NumActionRuns)
27+
assert.Equal(t, 2, repo.NumClosedActionRuns)
28+
29+
// now update will correct them, only num_actionr_runs and num_closed_action_runs should be updated
30+
err = UpdateRepoRunsNumbers(t.Context(), repo)
31+
assert.NoError(t, err)
32+
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
33+
assert.Equal(t, 5, repo.NumActionRuns)
34+
assert.Equal(t, 3, repo.NumClosedActionRuns)
35+
}

0 commit comments

Comments
 (0)