Skip to content

Commit 4825cb5

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Test query must have "order by" explicitly to avoid unstable results (go-gitea#24963) Help to recover from corrupted levelqueue (go-gitea#24912) [skip ci] Updated translations via Crowdin Remove meta tags `theme-color` and `default-theme` (go-gitea#24960) Add dark mode to API Docs (go-gitea#24971) Update JS dependencies (go-gitea#24969) Replace Fomantic reset module with our own (go-gitea#24948) simple docs fixes: 'pull request' page (en-us & zh-tw) link path to 'issue-pull-request-templates' (go-gitea#24961) Remove reference to caddy v1 in docs (go-gitea#24962) Improve and fix bugs surrounding reactions (go-gitea#24760) Use `[git.config]` for reflog cleaning up (go-gitea#24958) Improve logger Pause handling (go-gitea#24946) Do not output "Trace" level logs from process manager by default (go-gitea#24952) Make the 500 page load themes (go-gitea#24953) [skip ci] Updated translations via Crowdin docs: remove an extraneous whitespace (go-gitea#24949) Show `bot` label next to username when rendering autor link if the user is a bot (go-gitea#24943) Improve some Forms (go-gitea#24878) Improve queue and logger context (go-gitea#24924) Fix ref type error (go-gitea#24941)
2 parents f90f495 + ad13df3 commit 4825cb5

File tree

98 files changed

+1749
-1383
lines changed

Some content is hidden

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

98 files changed

+1749
-1383
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -693,17 +693,13 @@ LEVEL = Info
693693
;PULL = 300
694694
;GC = 60
695695

696-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
697-
;; Git Reflog timeout in days
698-
;[git.reflog]
699-
;ENABLED = true
700-
;EXPIRATION = 90
701-
702696
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
703697
;; Git config options
704698
;; This section only does "set" config, a removed config key from this section won't be removed from git config automatically. The format is `some.configKey = value`.
705699
;[git.config]
706700
;diff.algorithm = histogram
701+
;core.logAllRefUpdates = true
702+
;gc.reflogExpire = 90
707703

708704
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
709705
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1184,10 +1180,6 @@ LEVEL = Info
11841180
;; Number of line of codes shown for a code comment
11851181
;CODE_COMMENT_LINES = 4
11861182
;;
1187-
;; Value of `theme-color` meta tag, used by some mobile browers for chrome and
1188-
;; out-of-viewport areas. Default is unset which uses body color.
1189-
;THEME_COLOR_META_TAG =
1190-
;;
11911183
;; Max size of files to be displayed (default is 8MiB)
11921184
;MAX_DISPLAY_FILE_SIZE = 8388608
11931185
;;

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a
221221
- `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page.
222222
- `THEMES`: **auto,gitea,arc-green**: All available themes. Allow users select personalized themes.
223223
regardless of the value of `DEFAULT_THEME`.
224-
- `THEME_COLOR_META_TAG`: **\<empty\>**: Value of `theme-color` meta tag, used by some mobile browsers for chrome and out-of-viewport areas. Default is unset which uses body color.
225224
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
226225
- `REACTIONS`: All available reactions users can choose on issues/prs and comments
227226
Values can be emoji alias (:smile:) or a unicode emoji.
@@ -1065,17 +1064,14 @@ Default templates for project boards:
10651064
- `PULL`: **300**: Git pull from internal repositories timeout seconds.
10661065
- `GC`: **60**: Git repository GC timeout seconds.
10671066

1068-
### Git - Reflog settings (`git.reflog`)
1069-
1070-
- `ENABLED`: **true** Set to true to enable Git to write changes to reflogs in each repo.
1071-
- `EXPIRATION`: **90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1072-
10731067
### Git - Config options (`git.config`)
10741068

10751069
The key/value pairs in this section will be used as git config.
10761070
This section only does "set" config, a removed config key from this section won't be removed from git config automatically. The format is `some.configKey = value`.
10771071

10781072
- `diff.algorithm`: **histogram**
1073+
- `core.logAllRefUpdates`: **true**
1074+
- `gc.reflogExpire`: **90**
10791075

10801076
## Metrics (`metrics`)
10811077

docs/content/doc/administration/reverse-proxies.en-us.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ git.example.com {
191191
}
192192
```
193193

194-
If you still use Caddy v1, use:
195-
196-
```apacheconf
197-
git.example.com {
198-
proxy / localhost:3000
199-
}
200-
```
201-
202194
## Caddy with a sub-path
203195

204196
In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile:
@@ -212,14 +204,6 @@ git.example.com {
212204
}
213205
```
214206

215-
Or, for Caddy v1:
216-
217-
```apacheconf
218-
git.example.com {
219-
proxy /git/ localhost:3000
220-
}
221-
```
222-
223207
Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
224208

225209
## IIS

docs/content/doc/development/oauth2-provider.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ For public clients, a redirect URI of a loopback IP address such as `http://127.
9494
1. Redirect to user to the authorization endpoint in order to get their consent for accessing the resources:
9595

9696
```curl
97-
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE
97+
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&state=STATE
9898
```
9999

100100
The `CLIENT_ID` can be obtained by registering an application in the settings. The `STATE` is a random string that will be send back to your application after the user authorizes. The `state` parameter is optional but should be used to prevent CSRF attacks.

docs/content/doc/usage/pull-request.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ The first value of the list will be used in helpers.
6666

6767
## Pull Request Templates
6868

69-
You can find more information about pull request templates at the page [Issue and Pull Request templates](../issue-pull-request-templates).
69+
You can find more information about pull request templates at the page [Issue and Pull Request templates](issue-pull-request-templates).

docs/content/doc/usage/pull-request.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
3131

3232
## 合併請求範本
3333

34-
您可以在[問題與合併請求範本](../issue-pull-request-templates)找到更多關於合併請求範本的資訊。
34+
您可以在[問題與合併請求範本](issue-pull-request-templates)找到更多關於合併請求範本的資訊。

models/unittest/unit_tests.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,52 @@ import (
1919
const NonexistentID = int64(math.MaxInt64)
2020

2121
type testCond struct {
22-
query interface{}
23-
args []interface{}
22+
query any
23+
args []any
2424
}
2525

26+
type testOrderBy string
27+
2628
// Cond create a condition with arguments for a test
27-
func Cond(query interface{}, args ...interface{}) interface{} {
29+
func Cond(query any, args ...any) any {
2830
return &testCond{query: query, args: args}
2931
}
3032

31-
func whereConditions(e db.Engine, conditions []interface{}) db.Engine {
33+
// OrderBy creates "ORDER BY" a test query
34+
func OrderBy(orderBy string) any {
35+
return testOrderBy(orderBy)
36+
}
37+
38+
func whereOrderConditions(e db.Engine, conditions []any) db.Engine {
39+
orderBy := "id" // query must have the "ORDER BY", otherwise the result is not deterministic
3240
for _, condition := range conditions {
3341
switch cond := condition.(type) {
3442
case *testCond:
3543
e = e.Where(cond.query, cond.args...)
44+
case testOrderBy:
45+
orderBy = string(cond)
3646
default:
3747
e = e.Where(cond)
3848
}
3949
}
40-
return e
50+
return e.OrderBy(orderBy)
4151
}
4252

4353
// LoadBeanIfExists loads beans from fixture database if exist
44-
func LoadBeanIfExists(bean interface{}, conditions ...interface{}) (bool, error) {
54+
func LoadBeanIfExists(bean any, conditions ...any) (bool, error) {
4555
e := db.GetEngine(db.DefaultContext)
46-
return whereConditions(e, conditions).Get(bean)
56+
return whereOrderConditions(e, conditions).Get(bean)
4757
}
4858

4959
// BeanExists for testing, check if a bean exists
50-
func BeanExists(t assert.TestingT, bean interface{}, conditions ...interface{}) bool {
60+
func BeanExists(t assert.TestingT, bean any, conditions ...any) bool {
5161
exists, err := LoadBeanIfExists(bean, conditions...)
5262
assert.NoError(t, err)
5363
return exists
5464
}
5565

5666
// AssertExistsAndLoadBean assert that a bean exists and load it from the test database
57-
func AssertExistsAndLoadBean[T any](t assert.TestingT, bean T, conditions ...interface{}) T {
67+
func AssertExistsAndLoadBean[T any](t assert.TestingT, bean T, conditions ...any) T {
5868
exists, err := LoadBeanIfExists(bean, conditions...)
5969
assert.NoError(t, err)
6070
assert.True(t, exists,
@@ -64,9 +74,9 @@ func AssertExistsAndLoadBean[T any](t assert.TestingT, bean T, conditions ...int
6474
}
6575

6676
// AssertExistsAndLoadMap assert that a row exists and load it from the test database
67-
func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...interface{}) map[string]string {
77+
func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...any) map[string]string {
6878
e := db.GetEngine(db.DefaultContext).Table(table)
69-
res, err := whereConditions(e, conditions).Query()
79+
res, err := whereOrderConditions(e, conditions).Query()
7080
assert.NoError(t, err)
7181
assert.True(t, len(res) == 1,
7282
"Expected to find one row in %s (with conditions %+v), but found %d",
@@ -84,36 +94,36 @@ func AssertExistsAndLoadMap(t assert.TestingT, table string, conditions ...inter
8494
}
8595

8696
// GetCount get the count of a bean
87-
func GetCount(t assert.TestingT, bean interface{}, conditions ...interface{}) int {
97+
func GetCount(t assert.TestingT, bean any, conditions ...any) int {
8898
e := db.GetEngine(db.DefaultContext)
89-
count, err := whereConditions(e, conditions).Count(bean)
99+
count, err := whereOrderConditions(e, conditions).Count(bean)
90100
assert.NoError(t, err)
91101
return int(count)
92102
}
93103

94104
// AssertNotExistsBean assert that a bean does not exist in the test database
95-
func AssertNotExistsBean(t assert.TestingT, bean interface{}, conditions ...interface{}) {
105+
func AssertNotExistsBean(t assert.TestingT, bean any, conditions ...any) {
96106
exists, err := LoadBeanIfExists(bean, conditions...)
97107
assert.NoError(t, err)
98108
assert.False(t, exists)
99109
}
100110

101111
// AssertExistsIf asserts that a bean exists or does not exist, depending on
102112
// what is expected.
103-
func AssertExistsIf(t assert.TestingT, expected bool, bean interface{}, conditions ...interface{}) {
113+
func AssertExistsIf(t assert.TestingT, expected bool, bean any, conditions ...any) {
104114
exists, err := LoadBeanIfExists(bean, conditions...)
105115
assert.NoError(t, err)
106116
assert.Equal(t, expected, exists)
107117
}
108118

109119
// AssertSuccessfulInsert assert that beans is successfully inserted
110-
func AssertSuccessfulInsert(t assert.TestingT, beans ...interface{}) {
120+
func AssertSuccessfulInsert(t assert.TestingT, beans ...any) {
111121
err := db.Insert(db.DefaultContext, beans...)
112122
assert.NoError(t, err)
113123
}
114124

115125
// AssertCount assert the count of a bean
116-
func AssertCount(t assert.TestingT, bean, expected interface{}) {
126+
func AssertCount(t assert.TestingT, bean, expected any) {
117127
assert.EqualValues(t, expected, GetCount(t, bean))
118128
}
119129

models/user/user.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ func (u *User) IsIndividual() bool {
406406
return u.Type == UserTypeIndividual
407407
}
408408

409+
// IsBot returns whether or not the user is of type bot
410+
func (u *User) IsBot() bool {
411+
return u.Type == UserTypeBot
412+
}
413+
409414
// DisplayName returns full name if it's not empty,
410415
// returns username otherwise.
411416
func (u *User) DisplayName() string {

modules/git/git.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -201,23 +201,6 @@ func InitFull(ctx context.Context) (err error) {
201201
return syncGitConfig()
202202
}
203203

204-
func enableReflogs() error {
205-
if err := configSet("core.logAllRefUpdates", "true"); err != nil {
206-
return err
207-
}
208-
err := configSet("gc.reflogExpire", fmt.Sprintf("%d", setting.Git.Reflog.Expiration))
209-
return err
210-
}
211-
212-
func disableReflogs() error {
213-
if err := configUnsetAll("core.logAllRefUpdates", "true"); err != nil {
214-
return err
215-
} else if err := configUnsetAll("gc.reflogExpire", ""); err != nil {
216-
return err
217-
}
218-
return nil
219-
}
220-
221204
// syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem)
222205
func syncGitConfig() (err error) {
223206
if err = os.MkdirAll(HomeDir(), os.ModePerm); err != nil {
@@ -249,16 +232,6 @@ func syncGitConfig() (err error) {
249232
return err
250233
}
251234

252-
if setting.Git.Reflog.Enabled {
253-
if err := enableReflogs(); err != nil {
254-
return err
255-
}
256-
} else {
257-
if err := disableReflogs(); err != nil {
258-
return err
259-
}
260-
}
261-
262235
if CheckGitVersionAtLeast("2.10") == nil {
263236
if err := configSet("receive.advertisePushOptions", "true"); err != nil {
264237
return err

modules/graceful/context.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,8 @@ package graceful
55

66
import (
77
"context"
8-
"time"
98
)
109

11-
// ChannelContext is a context that wraps a channel and error as a context
12-
type ChannelContext struct {
13-
done <-chan struct{}
14-
err error
15-
}
16-
17-
// NewChannelContext creates a ChannelContext from a channel and error
18-
func NewChannelContext(done <-chan struct{}, err error) *ChannelContext {
19-
return &ChannelContext{
20-
done: done,
21-
err: err,
22-
}
23-
}
24-
25-
// Deadline returns the time when work done on behalf of this context
26-
// should be canceled. There is no Deadline for a ChannelContext
27-
func (ctx *ChannelContext) Deadline() (deadline time.Time, ok bool) {
28-
return deadline, ok
29-
}
30-
31-
// Done returns the channel provided at the creation of this context.
32-
// When closed, work done on behalf of this context should be canceled.
33-
func (ctx *ChannelContext) Done() <-chan struct{} {
34-
return ctx.done
35-
}
36-
37-
// Err returns nil, if Done is not closed. If Done is closed,
38-
// Err returns the error provided at the creation of this context
39-
func (ctx *ChannelContext) Err() error {
40-
select {
41-
case <-ctx.done:
42-
return ctx.err
43-
default:
44-
return nil
45-
}
46-
}
47-
48-
// Value returns nil for all calls as no values are or can be associated with this context
49-
func (ctx *ChannelContext) Value(key interface{}) interface{} {
50-
return nil
51-
}
52-
5310
// ShutdownContext returns a context.Context that is Done at shutdown
5411
// Callers using this context should ensure that they are registered as a running server
5512
// in order that they are waited for.

0 commit comments

Comments
 (0)