Skip to content

Commit d208187

Browse files
authored
Merge branch 'main' into fix-tmpl-ctx
2 parents 814c856 + 067b0c2 commit d208187

Some content is hidden

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

44 files changed

+2423
-3055
lines changed

.drone.yml

+21
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,9 @@ trigger:
10061006
event:
10071007
exclude:
10081008
- cron
1009+
paths:
1010+
exclude:
1011+
- docs/**
10091012

10101013
steps:
10111014
- name: fetch-tags
@@ -1070,6 +1073,9 @@ trigger:
10701073
event:
10711074
exclude:
10721075
- cron
1076+
paths:
1077+
exclude:
1078+
- docs/**
10731079

10741080
steps:
10751081
- name: fetch-tags
@@ -1298,6 +1304,9 @@ trigger:
12981304
event:
12991305
exclude:
13001306
- cron
1307+
paths:
1308+
exclude:
1309+
- docs/**
13011310

13021311
steps:
13031312
- name: fetch-tags
@@ -1362,6 +1371,9 @@ trigger:
13621371
event:
13631372
exclude:
13641373
- cron
1374+
paths:
1375+
exclude:
1376+
- docs/**
13651377

13661378
steps:
13671379
- name: fetch-tags
@@ -1424,6 +1436,9 @@ trigger:
14241436
event:
14251437
exclude:
14261438
- cron
1439+
paths:
1440+
exclude:
1441+
- docs/**
14271442

14281443
steps:
14291444
- name: fetch-tags
@@ -1571,6 +1586,9 @@ trigger:
15711586
event:
15721587
exclude:
15731588
- cron
1589+
paths:
1590+
exclude:
1591+
- docs/**
15741592

15751593
depends_on:
15761594
- docker-linux-amd64-release-version
@@ -1619,6 +1637,9 @@ trigger:
16191637
event:
16201638
exclude:
16211639
- cron
1640+
paths:
1641+
exclude:
1642+
- docs/**
16221643

16231644
depends_on:
16241645
- docker-linux-amd64-release

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ fomantic:
859859
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
860860
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
861861
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
862+
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
863+
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
862864
$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
863865
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
864866

custom/conf/app.example.ini

+6
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,9 @@ ROUTER = console
18711871
;;
18721872
;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
18731873
;MINIO_USE_SSL = false
1874+
;;
1875+
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
1876+
;MINIO_INSECURE_SKIP_VERIFY = false
18741877

18751878
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18761879
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2552,6 +2555,9 @@ ROUTER = console
25522555
;;
25532556
;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
25542557
;MINIO_USE_SSL = false
2558+
;;
2559+
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
2560+
;MINIO_INSECURE_SKIP_VERIFY = false
25552561

25562562
;[proxy]
25572563
;; Enable the proxy, all requests to external via HTTP will be affected

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

+6
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ Default templates for project boards:
854854
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when STORAGE_TYPE is `minio`
855855
- `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket only available when STORAGE_TYPE is `minio`
856856
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio`
857+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
857858

858859
## Log (`log`)
859860

@@ -1268,6 +1269,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`.
12681269
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
12691270
- `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
12701271
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1272+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
12711273

12721274
## Storage (`storage`)
12731275

@@ -1280,6 +1282,7 @@ Default storage configuration for attachments, lfs, avatars and etc.
12801282
- `MINIO_BUCKET`: **gitea**: Minio bucket to store the data only available when `STORAGE_TYPE` is `minio`
12811283
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
12821284
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1285+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
12831286

12841287
And you can also define a customize storage like below:
12851288

@@ -1298,6 +1301,8 @@ MINIO_BUCKET = gitea
12981301
MINIO_LOCATION = us-east-1
12991302
; Minio enabled ssl only available when STORAGE_TYPE is `minio`
13001303
MINIO_USE_SSL = false
1304+
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
1305+
MINIO_INSECURE_SKIP_VERIFY = false
13011306
```
13021307

13031308
And used by `[attachment]`, `[lfs]` and etc. as `STORAGE_TYPE`.
@@ -1318,6 +1323,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`.
13181323
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
13191324
- `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
13201325
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1326+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
13211327

13221328
## Proxy (`proxy`)
13231329

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

+2
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ MINIO_BUCKET = gitea
431431
MINIO_LOCATION = us-east-1
432432
; Minio enabled ssl only available when STORAGE_TYPE is `minio`
433433
MINIO_USE_SSL = false
434+
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
435+
MINIO_INSECURE_SKIP_VERIFY = false
434436
```
435437

436438
然后你在 `[attachment]`, `[lfs]` 等中可以把这个名字用作 `STORAGE_TYPE` 的值。

models/issues/stopwatch.go

+22-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"code.gitea.io/gitea/models/db"
12+
"code.gitea.io/gitea/models/repo"
1213
user_model "code.gitea.io/gitea/models/user"
1314
"code.gitea.io/gitea/modules/timeutil"
1415
"code.gitea.io/gitea/modules/util"
@@ -132,12 +133,26 @@ func StopwatchExists(userID, issueID int64) bool {
132133
}
133134

134135
// HasUserStopwatch returns true if the user has a stopwatch
135-
func HasUserStopwatch(ctx context.Context, userID int64) (exists bool, sw *Stopwatch, err error) {
136-
sw = new(Stopwatch)
136+
func HasUserStopwatch(ctx context.Context, userID int64) (exists bool, sw *Stopwatch, issue *Issue, err error) {
137+
type stopwatchIssueRepo struct {
138+
Stopwatch `xorm:"extends"`
139+
Issue `xorm:"extends"`
140+
repo.Repository `xorm:"extends"`
141+
}
142+
143+
swIR := new(stopwatchIssueRepo)
137144
exists, err = db.GetEngine(ctx).
145+
Table("stopwatch").
138146
Where("user_id = ?", userID).
139-
Get(sw)
140-
return exists, sw, err
147+
Join("INNER", "issue", "issue.id = stopwatch.issue_id").
148+
Join("INNER", "repository", "repository.id = issue.repo_id").
149+
Get(swIR)
150+
if exists {
151+
sw = &swIR.Stopwatch
152+
issue = &swIR.Issue
153+
issue.Repo = &swIR.Repository
154+
}
155+
return exists, sw, issue, err
141156
}
142157

143158
// FinishIssueStopwatchIfPossible if stopwatch exist then finish it otherwise ignore
@@ -217,23 +232,18 @@ func CreateIssueStopwatch(ctx context.Context, user *user_model.User, issue *Iss
217232
}
218233

219234
// if another stopwatch is running: stop it
220-
exists, sw, err := HasUserStopwatch(ctx, user.ID)
235+
exists, _, otherIssue, err := HasUserStopwatch(ctx, user.ID)
221236
if err != nil {
222237
return err
223238
}
224239
if exists {
225-
issue, err := GetIssueByID(ctx, sw.IssueID)
226-
if err != nil {
227-
return err
228-
}
229-
230-
if err := FinishIssueStopwatch(ctx, user, issue); err != nil {
240+
if err := FinishIssueStopwatch(ctx, user, otherIssue); err != nil {
231241
return err
232242
}
233243
}
234244

235245
// Create stopwatch
236-
sw = &Stopwatch{
246+
sw := &Stopwatch{
237247
UserID: user.ID,
238248
IssueID: issue.ID,
239249
}

models/issues/stopwatch_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ func TestStopwatchExists(t *testing.T) {
4545
func TestHasUserStopwatch(t *testing.T) {
4646
assert.NoError(t, unittest.PrepareTestDatabase())
4747

48-
exists, sw, err := issues_model.HasUserStopwatch(db.DefaultContext, 1)
48+
exists, sw, _, err := issues_model.HasUserStopwatch(db.DefaultContext, 1)
4949
assert.NoError(t, err)
5050
assert.True(t, exists)
5151
assert.Equal(t, int64(1), sw.ID)
5252

53-
exists, _, err = issues_model.HasUserStopwatch(db.DefaultContext, 3)
53+
exists, _, _, err = issues_model.HasUserStopwatch(db.DefaultContext, 3)
5454
assert.NoError(t, err)
5555
assert.False(t, exists)
5656
}

modules/setting/storage.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func getStorage(rootCfg ConfigProvider, name, typ string, targetSec *ini.Section
4141
sec.Key("MINIO_BUCKET").MustString("gitea")
4242
sec.Key("MINIO_LOCATION").MustString("us-east-1")
4343
sec.Key("MINIO_USE_SSL").MustBool(false)
44+
sec.Key("MINIO_INSECURE_SKIP_VERIFY").MustBool(false)
4445

4546
if targetSec == nil {
4647
targetSec, _ = rootCfg.NewSection(name)

modules/storage/minio.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ package storage
55

66
import (
77
"context"
8+
"crypto/tls"
89
"io"
10+
"net/http"
911
"net/url"
1012
"os"
1113
"path"
@@ -42,13 +44,14 @@ const MinioStorageType Type = "minio"
4244

4345
// MinioStorageConfig represents the configuration for a minio storage
4446
type MinioStorageConfig struct {
45-
Endpoint string `ini:"MINIO_ENDPOINT"`
46-
AccessKeyID string `ini:"MINIO_ACCESS_KEY_ID"`
47-
SecretAccessKey string `ini:"MINIO_SECRET_ACCESS_KEY"`
48-
Bucket string `ini:"MINIO_BUCKET"`
49-
Location string `ini:"MINIO_LOCATION"`
50-
BasePath string `ini:"MINIO_BASE_PATH"`
51-
UseSSL bool `ini:"MINIO_USE_SSL"`
47+
Endpoint string `ini:"MINIO_ENDPOINT"`
48+
AccessKeyID string `ini:"MINIO_ACCESS_KEY_ID"`
49+
SecretAccessKey string `ini:"MINIO_SECRET_ACCESS_KEY"`
50+
Bucket string `ini:"MINIO_BUCKET"`
51+
Location string `ini:"MINIO_LOCATION"`
52+
BasePath string `ini:"MINIO_BASE_PATH"`
53+
UseSSL bool `ini:"MINIO_USE_SSL"`
54+
InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"`
5255
}
5356

5457
// MinioStorage returns a minio bucket storage
@@ -90,8 +93,9 @@ func NewMinioStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error
9093
log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath)
9194

9295
minioClient, err := minio.New(config.Endpoint, &minio.Options{
93-
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
94-
Secure: config.UseSSL,
96+
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
97+
Secure: config.UseSSL,
98+
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
9599
})
96100
if err != nil {
97101
return nil, convertMinioErr(err)

0 commit comments

Comments
 (0)