Skip to content

Commit c098a04

Browse files
Merge branch 'main' into allow-cancelling-runs-stuck-waiting
2 parents a673e38 + a0f492d commit c098a04

File tree

16 files changed

+246
-121
lines changed

16 files changed

+246
-121
lines changed

.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: 1 addition & 1 deletion
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]

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
}

models/pull/review_state.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ func init() {
4949
db.RegisterModel(new(ReviewState))
5050
}
5151

52+
func (rs *ReviewState) GetViewedFileCount() int {
53+
if len(rs.UpdatedFiles) == 0 {
54+
return 0
55+
}
56+
var numViewedFiles int
57+
for _, state := range rs.UpdatedFiles {
58+
if state == Viewed {
59+
numViewedFiles++
60+
}
61+
}
62+
return numViewedFiles
63+
}
64+
5265
// GetReviewState returns the ReviewState with all given values prefilled, whether or not it exists in the database.
5366
// If the review didn't exist before in the database, it won't afterwards either.
5467
// The returned boolean shows whether the review exists in the database

models/user/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ func GetUserByEmail(ctx context.Context, email string) (*User, error) {
12621262
}
12631263

12641264
// Finally, if email address is the protected email address:
1265-
if strings.HasSuffix(email, "@"+setting.Service.NoReplyAddress) {
1266-
username := strings.TrimSuffix(email, "@"+setting.Service.NoReplyAddress)
1265+
if before, ok := strings.CutSuffix(email, "@"+setting.Service.NoReplyAddress); ok {
1266+
username := before
12671267
user := &User{}
12681268
has, err := db.GetEngine(ctx).Where("lower_name=?", username).Get(user)
12691269
if err != nil {

modules/setting/server.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ func loadServerFrom(rootCfg ConfigProvider) {
235235
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0")
236236
AcmeEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
237237
}
238-
if AcmeEmail == "" {
239-
log.Fatal("ACME Email is not set (ACME_EMAIL).")
240-
}
241238
} else {
242239
CertFile = sec.Key("CERT_FILE").String()
243240
KeyFile = sec.Key("KEY_FILE").String()

routers/web/repo/pull.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,16 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
782782
// as the viewed information is designed to be loaded only on latest PR
783783
// diff and if you're signed in.
784784
var reviewState *pull_model.ReviewState
785+
var numViewedFiles int
785786
if ctx.IsSigned && isShowAllCommits {
786787
reviewState, err = gitdiff.SyncUserSpecificDiff(ctx, ctx.Doer.ID, pull, gitRepo, diff, diffOptions)
787788
if err != nil {
788789
ctx.ServerError("SyncUserSpecificDiff", err)
789790
return
790791
}
792+
if reviewState != nil {
793+
numViewedFiles = reviewState.GetViewedFileCount()
794+
}
791795
}
792796

793797
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, beforeCommitID, afterCommitID)
@@ -796,10 +800,11 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
796800
return
797801
}
798802
ctx.Data["DiffShortStat"] = diffShortStat
803+
ctx.Data["NumViewedFiles"] = numViewedFiles
799804

800805
ctx.PageData["prReview"] = map[string]any{
801806
"numberOfFiles": diffShortStat.NumFiles,
802-
"numberOfViewedFiles": diff.NumViewedFiles,
807+
"numberOfViewedFiles": numViewedFiles,
803808
}
804809

805810
if err = diff.LoadComments(ctx, issue, ctx.Doer, ctx.Data["ShowOutdatedComments"].(bool)); err != nil {

0 commit comments

Comments
 (0)