Skip to content

Commit d52c9cd

Browse files
committed
Merge branch 'main' into issue-content-history
2 parents fd792fd + 8fb3a50 commit d52c9cd

Some content is hidden

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

68 files changed

+1625
-1036
lines changed
File renamed without changes.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Bug Report
2+
description: Found something you weren't expecting? Report it here!
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
8+
- type: markdown
9+
attributes:
10+
value: |
11+
1. Please speak English, this is the language all maintainers can speak and write.
12+
2. Please ask questions or configuration/deploy problems on our Discord
13+
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
14+
3. Please take a moment to check that your issue doesn't already exist.
15+
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
16+
5. Please give all relevant information below for bug reports, because
17+
incomplete details will be handled as an invalid report.
18+
- type: input
19+
id: gitea-ver
20+
attributes:
21+
label: Gitea Version
22+
description: Gitea version (or commit reference) your instance is running
23+
validations:
24+
required: true
25+
- type: input
26+
id: git-ver
27+
attributes:
28+
label: Git Version
29+
description: The version of git running on the server's systemm
30+
- type: input
31+
id: os-ver
32+
attributes:
33+
label: Operating System
34+
description: The operating system you are using to run Gitea
35+
- type: textarea
36+
id: run-info
37+
attributes:
38+
label: How are you running Gitea?
39+
description: |
40+
Please include information on whether you built gitea yourself, used one of our downloads, are using https://try.gitea.io or are using some other package
41+
Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc.
42+
If you are using a package or systemd tell us what distribution you are using
43+
validations:
44+
required: true
45+
- type: dropdown
46+
id: database
47+
attributes:
48+
label: Database
49+
description: What database system are you running?
50+
options:
51+
- PostgreSQL
52+
- MySQL
53+
- MSSQL
54+
- SQLite
55+
- type: dropdown
56+
id: can-reproduce
57+
attributes:
58+
label: Can you reproduce the bug on the Gitea demo site?
59+
description: |
60+
If so, please provide a URL in the Description field
61+
URL of Gitea demo: https://try.gitea.io
62+
options:
63+
- "Yes"
64+
- "No"
65+
validations:
66+
required: true
67+
- type: markdown
68+
attributes:
69+
value: |
70+
It really is important to provide pertinent logs
71+
Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems
72+
In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini
73+
- type: input
74+
id: logs
75+
attributes:
76+
label: Log Gist
77+
description: Please provide a gist URL of your logs, with any sensitive information (e.g. API keys) removed/hidden
78+
- type: textarea
79+
id: description
80+
attributes:
81+
label: Description
82+
description: |
83+
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see above)
84+
If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services.
85+
- type: textarea
86+
id: screenshots
87+
attributes:
88+
label: Screenshots
89+
description: If this issue involves the Web Interface, please provide a screenshot or multiple screenshots

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Security Concern
4+
url: https://tinyurl.com/security-gitea
5+
about: For security concerns, please send a mail to security@gitea.io instead of opening a public issue.
6+
- name: Discord Server
7+
url: https://discord.gg/gitea
8+
about: Please ask questions and discuss configuration or deployment problems here.
9+
- name: Discourse Forum
10+
url: https://discourse.gitea.io
11+
about: Questions and configuration or deployment problems can also be discussed on our forum.
12+
- name: Frequently Asked Questions
13+
url: https://docs.gitea.io/en-us/faq
14+
about: Please check if your question isn't mentioned here.
15+
- name: Crowdin Translations
16+
url: https://crowdin.com/project/gitea
17+
about: Translations are managed here.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Feature Request
2+
description: Got an idea for a feature that Gitea doesn't have currently? Submit your idea here!
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
1. Please speak English, this is the language all maintainers can speak and write.
8+
2. Please ask questions or configuration/deploy problems on our Discord
9+
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
10+
3. Please take a moment to check that your feature hasn't already been suggested.
11+
- type: textarea
12+
id: description
13+
attributes:
14+
label: Feature Description
15+
placeholder: |
16+
I think it would be great if Gitea had...
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: screenshots
21+
attributes:
22+
label: Screenshots
23+
description: If you can, provide screenshots of an implementation on another site e.g. GitHub
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Web Interface Bug Report
2+
description: Something doesn't look quite as it should? Report it here!
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
8+
- type: markdown
9+
attributes:
10+
value: |
11+
1. Please speak English, this is the language all maintainers can speak and write.
12+
2. Please ask questions or configuration/deploy problems on our Discord
13+
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
14+
3. Please take a moment to check that your issue doesn't already exist.
15+
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
16+
5. Please give all relevant information below for bug reports, because
17+
incomplete details will be handled as an invalid report.
18+
- type: input
19+
id: gitea-ver
20+
attributes:
21+
label: Gitea Version
22+
description: Gitea version (or commit reference) your instance is running
23+
validations:
24+
required: true
25+
- type: input
26+
id: os-ver
27+
attributes:
28+
label: Operating System
29+
description: The operating system you are using to access Gitea
30+
- type: input
31+
id: browser-ver
32+
attributes:
33+
label: Browser Version
34+
description: The browser and version that you are using to access Gitea
35+
validations:
36+
required: true
37+
- type: dropdown
38+
id: can-reproduce
39+
attributes:
40+
label: Can you reproduce the bug on the Gitea demo site?
41+
description: |
42+
If so, please provide a URL in the Description field
43+
URL of Gitea demo: https://try.gitea.io
44+
options:
45+
- "Yes"
46+
- "No"
47+
validations:
48+
required: true
49+
- type: textarea
50+
id: description
51+
attributes:
52+
label: Description
53+
description: |
54+
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see above)
55+
If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services.
56+
- type: textarea
57+
id: screenshots
58+
attributes:
59+
label: Screenshots
60+
description: Please provide at least 1 screenshot showing the issue.
61+
validations:
62+
required: true

cmd/admin_auth_ldap.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ var (
8989
Name: "public-ssh-key-attribute",
9090
Usage: "The attribute of the user’s LDAP record containing the user’s public ssh key.",
9191
},
92+
cli.BoolFlag{
93+
Name: "skip-local-2fa",
94+
Usage: "Set to true to skip local 2fa for users authenticated by this source",
95+
},
9296
}
9397

9498
ldapBindDnCLIFlags = append(commonLdapCLIFlags,
@@ -245,6 +249,10 @@ func parseLdapConfig(c *cli.Context, config *ldap.Source) error {
245249
if c.IsSet("allow-deactivate-all") {
246250
config.AllowDeactivateAll = c.Bool("allow-deactivate-all")
247251
}
252+
if c.IsSet("skip-local-2fa") {
253+
config.SkipLocalTwoFA = c.Bool("skip-local-2fa")
254+
}
255+
248256
return nil
249257
}
250258

docs/content/doc/installation/database-preparation.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ menu:
1515

1616
# Database Preparation
1717

18-
You need a database to use Gitea. Gitea supports PostgreSQL, MySQL, SQLite, and MSSQL. This page will guide into preparing database. Only PostgreSQL and MySQL will be covered here since those database engines are widely-used in production.
18+
You need a database to use Gitea. Gitea supports PostgreSQL (>=10), MySQL (>=5.7), SQLite, and MSSQL (>=2008R2 SP3). This page will guide into preparing database. Only PostgreSQL and MySQL will be covered here since those database engines are widely-used in production.
1919

2020
Database instance can be on same machine as Gitea (local database setup), or on different machine (remote database).
2121

docs/content/page/index.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.
6969
- Logging
7070
- Configuration
7171
- Databases
72-
- MySQL
73-
- PostgreSQL
72+
- MySQL (>=5.7)
73+
- PostgreSQL (>=10)
7474
- SQLite3
75-
- MSSQL
75+
- MSSQL (>=2008R2 SP3)
7676
- TiDB (experimental, not recommended)
7777
- Configuration file
7878
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ require (
139139
mvdan.cc/xurls/v2 v2.2.0
140140
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
141141
xorm.io/builder v0.3.9
142-
xorm.io/xorm v1.2.2
142+
xorm.io/xorm v1.2.4
143143
)
144144

145145
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,5 +1761,5 @@ xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
17611761
xorm.io/builder v0.3.9 h1:Sd65/LdWyO7LR8+Cbd+e7mm3sK/7U9k0jS3999IDHMc=
17621762
xorm.io/builder v0.3.9/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
17631763
xorm.io/xorm v1.0.6/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
1764-
xorm.io/xorm v1.2.2 h1:FFBOEvJ++8fYBA9cywf2sxDVmFktl1SpJzTAG1ab06Y=
1765-
xorm.io/xorm v1.2.2/go.mod h1:fTG8tSjk6O1BYxwuohZUK+S1glnRycsCF05L1qQyEU0=
1764+
xorm.io/xorm v1.2.4 h1:2MQV4wJt4kY6CYJsLxjCLzBen7+aqVxqDTIwfnR59g4=
1765+
xorm.io/xorm v1.2.4/go.mod h1:fTG8tSjk6O1BYxwuohZUK+S1glnRycsCF05L1qQyEU0=

models/attachment.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,16 @@ func IterateAttachment(f func(attach *Attachment) error) error {
272272
}
273273
}
274274
}
275+
276+
// CountOrphanedAttachments returns the number of bad attachments
277+
func CountOrphanedAttachments() (int64, error) {
278+
return x.Where("(issue_id > 0 and issue_id not in (select id from issue)) or (release_id > 0 and release_id not in (select id from `release`))").
279+
Count(new(Attachment))
280+
}
281+
282+
// DeleteOrphanedAttachments delete all bad attachments
283+
func DeleteOrphanedAttachments() error {
284+
_, err := x.Where("(issue_id > 0 and issue_id not in (select id from issue)) or (release_id > 0 and release_id not in (select id from `release`))").
285+
Delete(new(Attachment))
286+
return err
287+
}

models/notification.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,20 +772,20 @@ func setRepoNotificationStatusReadIfUnread(e Engine, userID, repoID int64) error
772772
}
773773

774774
// SetNotificationStatus change the notification status
775-
func SetNotificationStatus(notificationID int64, user *User, status NotificationStatus) error {
775+
func SetNotificationStatus(notificationID int64, user *User, status NotificationStatus) (*Notification, error) {
776776
notification, err := getNotificationByID(x, notificationID)
777777
if err != nil {
778-
return err
778+
return notification, err
779779
}
780780

781781
if notification.UserID != user.ID {
782-
return fmt.Errorf("Can't change notification of another user: %d, %d", notification.UserID, user.ID)
782+
return nil, fmt.Errorf("Can't change notification of another user: %d, %d", notification.UserID, user.ID)
783783
}
784784

785785
notification.Status = status
786786

787787
_, err = x.ID(notificationID).Update(notification)
788-
return err
788+
return notification, err
789789
}
790790

791791
// GetNotificationByID return notification by ID

models/notification_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ func TestSetNotificationStatus(t *testing.T) {
7676
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
7777
notf := AssertExistsAndLoadBean(t,
7878
&Notification{UserID: user.ID, Status: NotificationStatusRead}).(*Notification)
79-
assert.NoError(t, SetNotificationStatus(notf.ID, user, NotificationStatusPinned))
79+
_, err := SetNotificationStatus(notf.ID, user, NotificationStatusPinned)
80+
assert.NoError(t, err)
8081
AssertExistsAndLoadBean(t,
8182
&Notification{ID: notf.ID, Status: NotificationStatusPinned})
8283

83-
assert.Error(t, SetNotificationStatus(1, user, NotificationStatusRead))
84-
assert.Error(t, SetNotificationStatus(NonexistentID, user, NotificationStatusRead))
84+
_, err = SetNotificationStatus(1, user, NotificationStatusRead)
85+
assert.Error(t, err)
86+
_, err = SetNotificationStatus(NonexistentID, user, NotificationStatusRead)
87+
assert.Error(t, err)
8588
}
8689

8790
func TestUpdateNotificationStatuses(t *testing.T) {

modules/context/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ func (ctx *APIContext) RequireCSRF() {
214214

215215
// CheckForOTP validates OTP
216216
func (ctx *APIContext) CheckForOTP() {
217+
if skip, ok := ctx.Data["SkipLocalTwoFA"]; ok && skip.(bool) {
218+
return // Skip 2FA
219+
}
220+
217221
otpHeader := ctx.Req.Header.Get("X-Gitea-OTP")
218222
twofa, err := models.GetTwoFactorByUID(ctx.Context.User.ID)
219223
if err != nil {

modules/context/auth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ func ToggleAPI(options *ToggleOptions) func(ctx *APIContext) {
151151
return
152152
}
153153
if ctx.IsSigned && ctx.IsBasicAuth {
154+
if skip, ok := ctx.Data["SkipLocalTwoFA"]; ok && skip.(bool) {
155+
return // Skip 2FA
156+
}
154157
twofa, err := models.GetTwoFactorByUID(ctx.User.ID)
155158
if err != nil {
156159
if models.IsErrTwoFactorNotEnrolled(err) {

modules/doctor/dbconsistency.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
7474
}
7575
}
7676

77+
// find releases without existing repository
78+
count, err = models.CountOrphanedObjects("release", "repository", "release.repo_id=repository.id")
79+
if err != nil {
80+
logger.Critical("Error: %v whilst counting orphaned objects", err)
81+
return err
82+
}
83+
if count > 0 {
84+
if autofix {
85+
if err = models.DeleteOrphanedObjects("release", "repository", "release.repo_id=repository.id"); err != nil {
86+
logger.Critical("Error: %v whilst deleting orphaned objects", err)
87+
return err
88+
}
89+
logger.Info("%d releases without existing repository deleted", count)
90+
} else {
91+
logger.Warn("%d releases without existing repository", count)
92+
}
93+
}
94+
7795
// find pulls without existing issues
7896
count, err = models.CountOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id")
7997
if err != nil {
@@ -110,6 +128,24 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
110128
}
111129
}
112130

131+
// find attachments without existing issues or releases
132+
count, err = models.CountOrphanedAttachments()
133+
if err != nil {
134+
logger.Critical("Error: %v whilst counting orphaned objects", err)
135+
return err
136+
}
137+
if count > 0 {
138+
if autofix {
139+
if err = models.DeleteOrphanedAttachments(); err != nil {
140+
logger.Critical("Error: %v whilst deleting orphaned objects", err)
141+
return err
142+
}
143+
logger.Info("%d attachments without existing issue or release deleted", count)
144+
} else {
145+
logger.Warn("%d attachments without existing issue or release", count)
146+
}
147+
}
148+
113149
// find null archived repositories
114150
count, err = models.CountNullArchivedRepository()
115151
if err != nil {

0 commit comments

Comments
 (0)