Skip to content

Commit 6931d42

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix autofocus behavior (go-gitea#34397) Fix incorrect divergence cache after switching default branch (go-gitea#34370) Add a button editing action secret (go-gitea#34348) Fix LFS file not stored in LFS when uploaded/edited via API or web UI (go-gitea#34367) [skip ci] Updated translations via Crowdin Fix "The sidebar of the repository file list does not have a fixed height go-gitea#34298" (go-gitea#34321) feat: add label 'state' to metric 'gitea_users' (go-gitea#34326) Update JS and PY dependencies (go-gitea#34391) Upgrade go-github v61 -> v71 (go-gitea#34385) Bump `@github/relative-time-element` to v4.4.7 (go-gitea#34384) gitignore: Visual Studio settings folder (go-gitea#34375) Grey out expired artifact on Artifacts list (go-gitea#34314)
2 parents 1b6e855 + 44aadc3 commit 6931d42

Some content is hidden

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

71 files changed

+1514
-973
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ _test
2222
.vscode
2323
__debug_bin*
2424

25+
# Visual Studio
26+
/.vs/
27+
2528
*.cgo1.go
2629
*.cgo2.c
2730
_cgo_defun.c

assets/go-licenses.json

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

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"strings"
1919
"syscall"
2020

21-
"github.com/google/go-github/v61/github"
21+
"github.com/google/go-github/v71/github"
2222
"github.com/urfave/cli/v2"
2323
"gopkg.in/yaml.v3"
2424
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ require (
6666
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
6767
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
6868
github.com/golang-jwt/jwt/v5 v5.2.2
69-
github.com/google/go-github/v61 v61.0.0
69+
github.com/google/go-github/v71 v71.0.0
7070
github.com/google/licenseclassifier/v2 v2.0.0
7171
github.com/google/pprof v0.0.0-20250422154841-e1f9c1950416
7272
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
420420
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
421421
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
422422
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
423-
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
424-
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
423+
github.com/google/go-github/v71 v71.0.0 h1:Zi16OymGKZZMm8ZliffVVJ/Q9YZreDKONCr+WUd0Z30=
424+
github.com/google/go-github/v71 v71.0.0/go.mod h1:URZXObp2BLlMjwu0O8g4y6VBneUj2bCHgnI8FfgZ51M=
425425
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
426426
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
427427
github.com/google/go-tpm v0.9.3 h1:+yx0/anQuGzi+ssRqeD6WpXjW2L/V0dItUayO0i9sRc=

models/activities/statistic.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ import (
1717
repo_model "code.gitea.io/gitea/models/repo"
1818
user_model "code.gitea.io/gitea/models/user"
1919
"code.gitea.io/gitea/models/webhook"
20+
"code.gitea.io/gitea/modules/optional"
2021
"code.gitea.io/gitea/modules/setting"
2122
)
2223

2324
// Statistic contains the database statistics
2425
type Statistic struct {
2526
Counter struct {
26-
User, Org, PublicKey,
27+
UsersActive, UsersNotActive,
28+
Org, PublicKey,
2729
Repo, Watch, Star, Access,
2830
Issue, IssueClosed, IssueOpen,
2931
Comment, Oauth, Follow,
@@ -53,7 +55,19 @@ type IssueByRepositoryCount struct {
5355
// GetStatistic returns the database statistics
5456
func GetStatistic(ctx context.Context) (stats Statistic) {
5557
e := db.GetEngine(ctx)
56-
stats.Counter.User = user_model.CountUsers(ctx, nil)
58+
59+
// Number of active users
60+
usersActiveOpts := user_model.CountUserFilter{
61+
IsActive: optional.Some(true),
62+
}
63+
stats.Counter.UsersActive = user_model.CountUsers(ctx, &usersActiveOpts)
64+
65+
// Number of inactive users
66+
usersNotActiveOpts := user_model.CountUserFilter{
67+
IsActive: optional.Some(false),
68+
}
69+
stats.Counter.UsersNotActive = user_model.CountUsers(ctx, &usersNotActiveOpts)
70+
5771
stats.Counter.Org, _ = db.Count[organization.Organization](ctx, organization.FindOrgOptions{IncludePrivate: true})
5872
stats.Counter.PublicKey, _ = e.Count(new(asymkey_model.PublicKey))
5973
stats.Counter.Repo, _ = repo_model.CountRepositories(ctx, repo_model.CountRepositoryOptions{})

models/user/user.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ func IsLastAdminUser(ctx context.Context, user *User) bool {
828828
type CountUserFilter struct {
829829
LastLoginSince *int64
830830
IsAdmin optional.Option[bool]
831+
IsActive optional.Option[bool]
831832
}
832833

833834
// CountUsers returns number of users.
@@ -848,6 +849,10 @@ func countUsers(ctx context.Context, opts *CountUserFilter) int64 {
848849
if opts.IsAdmin.Has() {
849850
cond = cond.And(builder.Eq{"is_admin": opts.IsAdmin.Value()})
850851
}
852+
853+
if opts.IsActive.Has() {
854+
cond = cond.And(builder.Eq{"is_active": opts.IsActive.Value()})
855+
}
851856
}
852857

853858
count, err := sess.Where(cond).Count(new(User))

modules/git/attribute/checker.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ func checkAttrCommand(gitRepo *git.Repository, treeish string, filenames, attrib
3939
)
4040
cancel = deleteTemporaryFile
4141
}
42-
} // else: no treeish, assume it is a not a bare repo, read from working directory
42+
} else {
43+
// Read from existing index, in cases where the repo is bare and has an index,
44+
// or the work tree contains unstaged changes that shouldn't affect the attribute check.
45+
// It is caller's responsibility to add changed ".gitattributes" into the index if they want to respect the new changes.
46+
cmd.AddArguments("--cached")
47+
}
4348

4449
cmd.AddDynamicArguments(attributes...)
4550
if len(filenames) > 0 {

modules/git/attribute/checker_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,18 @@ func Test_Checker(t *testing.T) {
5757
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
5858
})
5959

60+
t.Run("Run git check-attr in bare repository using index", func(t *testing.T) {
61+
attrs, err := CheckAttributes(t.Context(), gitRepo, "", CheckAttributeOpts{
62+
Filenames: []string{"i-am-a-python.p"},
63+
Attributes: LinguistAttributes,
64+
})
65+
assert.NoError(t, err)
66+
assert.Len(t, attrs, 1)
67+
assert.Equal(t, expectedAttrs(), attrs["i-am-a-python.p"])
68+
})
69+
6070
if !git.DefaultFeatures().SupportCheckAttrOnBare {
61-
t.Skip("git version 2.40 is required to support run check-attr on bare repo")
71+
t.Skip("git version 2.40 is required to support run check-attr on bare repo without using index")
6272
return
6373
}
6474

modules/metrics/collector.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func NewCollector() Collector {
184184
Users: prometheus.NewDesc(
185185
namespace+"users",
186186
"Number of Users",
187-
nil, nil,
187+
[]string{"state"}, nil,
188188
),
189189
Watches: prometheus.NewDesc(
190190
namespace+"watches",
@@ -373,7 +373,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
373373
ch <- prometheus.MustNewConstMetric(
374374
c.Users,
375375
prometheus.GaugeValue,
376-
float64(stats.Counter.User),
376+
float64(stats.Counter.UsersActive),
377+
"active", // state label
378+
)
379+
ch <- prometheus.MustNewConstMetric(
380+
c.Users,
381+
prometheus.GaugeValue,
382+
float64(stats.Counter.UsersNotActive),
383+
"inactive", // state label
377384
)
378385
ch <- prometheus.MustNewConstMetric(
379386
c.Watches,

0 commit comments

Comments
 (0)