Skip to content

Commit 9b3674e

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: (25 commits) [skip ci] Updated translations via Crowdin Respect user's locale when rendering the date range in the repo activity page (go-gitea#21410) Consolidate more CSS colors into variables (go-gitea#21402) Add HEAD fix to gitea doctor (go-gitea#21352) Contribution guidelines (go-gitea#21425) Refactor Gitpod configuration to improve quick spin up of automated dev environments (go-gitea#21411) Support instance-wide OAuth2 applications (go-gitea#21335) Case-insensitive NuGet symbol file GUID (go-gitea#21409) Add generic set type (go-gitea#21408) Improve OAuth integration tests (go-gitea#21390) Make e-mail sanity check more precise (go-gitea#20991) Fix broken link to frontend guidelines in hacking guidelines (go-gitea#21382) Use Name instead of DisplayName in LFS Lock (go-gitea#21415) [skip ci] Updated translations via Crowdin feat(pr review): add more space on mobile (go-gitea#21326) Bump `golang.org/x/text` (go-gitea#21412) Update gitea.service (go-gitea#21399) Do DB update after merge in hammer context (go-gitea#21401) add gitpod config (go-gitea#20995) Remove cancel button in repo creation page (go-gitea#21381) ...
2 parents 63c503f + cda2c38 commit 9b3674e

Some content is hidden

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

82 files changed

+920
-515
lines changed

.gitpod.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
tasks:
2+
- name: Setup
3+
init: |
4+
make deps
5+
make build
6+
command: |
7+
gp sync-done setup
8+
exit 0
9+
- name: Run frontend
10+
command: |
11+
gp sync-await setup
12+
make watch-frontend
13+
- name: Run backend
14+
command: |
15+
gp sync-await setup
16+
mkdir -p custom/conf/
17+
echo -e "[server]\nROOT_URL=$(gp url 3000)/" > custom/conf/app.ini
18+
echo -e "\n[database]\nDB_TYPE = sqlite3\nPATH = $GITPOD_REPO_ROOT/data/gitea.db" >> custom/conf/app.ini
19+
export TAGS="sqlite sqlite_unlock_notify"
20+
make watch-backend
21+
- name: Run docs
22+
before: sudo bash -c "$(grep 'https://github.com/gohugoio/hugo/releases/download' Makefile | tr -d '\')" # install hugo
23+
command: cd docs && make clean update && hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
24+
25+
vscode:
26+
extensions:
27+
- editorconfig.editorconfig
28+
- dbaeumer.vscode-eslint
29+
- golang.go
30+
- stylelint.vscode-stylelint
31+
- DavidAnson.vscode-markdownlint
32+
- johnsoncodehk.volar
33+
- ms-azuretools.vscode-docker
34+
35+
ports:
36+
- name: Gitea
37+
port: 3000
38+
- name: Docs
39+
port: 1313

CONTRIBUTING.md

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,22 @@ import (
170170

171171
To maintain understandable code and avoid circular dependencies it is important to have a good structure of the code. The Gitea code is divided into the following parts:
172172

173-
- **integration:** Integration tests
174173
- **models:** Contains the data structures used by xorm to construct database tables. It also contains supporting functions to query and update the database. Dependencies to other code in Gitea should be avoided although some modules might be needed (for example for logging).
175174
- **models/fixtures:** Sample model data used in integration tests.
176175
- **models/migrations:** Handling of database migrations between versions. PRs that changes a database structure shall also have a migration step.
177-
- **modules:** Different modules to handle specific functionality in Gitea.
176+
- **modules:** Different modules to handle specific functionality in Gitea. Shall only depend on other modules but not other packages (models, services).
178177
- **public:** Frontend files (javascript, images, css, etc.)
179-
- **routers:** Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) shall not depend on routers
178+
- **routers:** Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) shall not depend on routers.
180179
- **services:** Support functions for common routing operations. Uses models and modules to handle the request.
181180
- **templates:** Golang templates for generating the html output.
181+
- **tests/e2e:** End to end tests
182+
- **tests/integration:** Integration tests
182183
- **vendor:** External code that Gitea depends on.
183184

185+
## Documentation
186+
187+
If you add a new feature or change an existing aspect of Gitea, the documentation for that feature must be created or updated.
188+
184189
## API v1
185190

186191
The API is documented by [swagger](http://try.gitea.io/api/swagger) and is based on [GitHub API v3](https://developer.github.com/v3/).
@@ -229,27 +234,6 @@ An endpoint which changes/edits an object expects all fields to be optional (exc
229234
- support pagination (`page` & `limit` options in query)
230235
- set `X-Total-Count` header via **SetTotalCountHeader** ([example](https://github.com/go-gitea/gitea/blob/7aae98cc5d4113f1e9918b7ee7dd09f67c189e3e/routers/api/v1/repo/issue.go#L444))
231236

232-
## Large Character Comments
233-
234-
Throughout the codebase there are large-text comments for sections of code, e.g.:
235-
236-
```go
237-
// __________ .__
238-
// \______ \ _______ _|__| ______ _ __
239-
// | _// __ \ \/ / |/ __ \ \/ \/ /
240-
// | | \ ___/\ /| \ ___/\ /
241-
// |____|_ /\___ >\_/ |__|\___ >\/\_/
242-
// \/ \/ \/
243-
```
244-
245-
These were created using the `figlet` tool with the `graffiti` font.
246-
247-
A simple way of creating these is to use the following:
248-
249-
```bash
250-
figlet -f graffiti Review | sed -e's+^+// +' - | xclip -sel clip -in
251-
```
252-
253237
## Backports and Frontports
254238

255239
Occasionally backports of PRs are required.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<a href="https://opensource.org/licenses/MIT" title="License: MIT">
3434
<img src="https://img.shields.io/badge/License-MIT-blue.svg">
3535
</a>
36+
<a href="https://gitpod.io/#https://github.com/go-gitea/gitea">
37+
<img
38+
src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod"
39+
alt="Contribute with Gitpod"
40+
/>
41+
</a>
3642
<a href="https://crowdin.com/project/gitea" title="Crowdin">
3743
<img src="https://badges.crowdin.net/gitea/localized.svg">
3844
</a>

README_ZH.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<a href="https://opensource.org/licenses/MIT" title="License: MIT">
3434
<img src="https://img.shields.io/badge/License-MIT-blue.svg">
3535
</a>
36+
<a href="https://gitpod.io/#https://github.com/go-gitea/gitea">
37+
<img
38+
src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod"
39+
alt="Contribute with Gitpod"
40+
/>
41+
</a>
3642
<a href="https://crowdin.com/project/gitea" title="Crowdin">
3743
<img src="https://badges.crowdin.net/gitea/localized.svg">
3844
</a>

contrib/systemd/gitea.service

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ After=network.target
4949
###
5050

5151
[Service]
52-
# Modify these two values and uncomment them if you have
53-
# repos with lots of files and get an HTTP error 500 because
54-
# of that
55-
###
56-
#LimitMEMLOCK=infinity
57-
#LimitNOFILE=65535
52+
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
53+
# LimitNOFILE=524288:524288
5854
RestartSec=2s
5955
Type=simple
6056
User=git

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
537537
## Camo (`camo`)
538538

539539
- `ENABLED`: **false**: Enable media proxy, we support images only at the moment.
540-
- `SERVER_URL`: **<empty>**: url of camo server, it **is required** if camo is enabled.
541-
- `HMAC_KEY`: **<empty>**: Provide the HMAC key for encoding urls, it **is required** if camo is enabled.
542-
- `ALLWAYS`: **false**: Set to true to use camo for https too lese only non https urls are proxyed
540+
- `SERVER_URL`: **<empty>**: URL of camo server, it **is required** if camo is enabled.
541+
- `HMAC_KEY`: **<empty>**: Provide the HMAC key for encoding URLs, it **is required** if camo is enabled.
542+
- `ALLWAYS`: **false**: Set to true to use camo for both HTTP and HTTPS content, otherwise only non-HTTPS URLs are proxied
543543

544544
## OpenID (`openid`)
545545

docs/content/doc/developers/hacking-on-gitea.en-us.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ menu:
1919

2020
{{< toc >}}
2121

22+
## Quickstart
23+
24+
To get a quick working development environment you could use Gitpod.
25+
26+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea)
27+
2228
## Installing go
2329

2430
You should [install go](https://golang.org/doc/install) and set up your go
@@ -171,7 +177,7 @@ server as mentioned above.
171177

172178
### Working on JS and CSS
173179

174-
Frontend development should follow [Guidelines for Frontend Development](./guidelines-frontend.md)
180+
Frontend development should follow [Guidelines for Frontend Development]({{< relref "doc/developers/guidelines-frontend.en-us.md" >}})
175181

176182
To build with frontend resources, either use the `watch-frontend` target mentioned above or just build once:
177183

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ require (
9898
golang.org/x/net v0.0.0-20220927171203-f486391704dc
9999
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1
100100
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec
101-
golang.org/x/text v0.3.7
101+
golang.org/x/text v0.3.8
102102
golang.org/x/tools v0.1.12
103103
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
104104
gopkg.in/ini.v1 v1.67.0

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
18911891
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
18921892
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
18931893
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
1894-
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
18951894
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
1895+
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
1896+
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
18961897
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
18971898
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
18981899
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

models/activities/action_list.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ import (
1818
type ActionList []*Action
1919

2020
func (actions ActionList) getUserIDs() []int64 {
21-
userIDs := make(map[int64]struct{}, len(actions))
21+
userIDs := make(container.Set[int64], len(actions))
2222
for _, action := range actions {
23-
if _, ok := userIDs[action.ActUserID]; !ok {
24-
userIDs[action.ActUserID] = struct{}{}
25-
}
23+
userIDs.Add(action.ActUserID)
2624
}
27-
return container.KeysInt64(userIDs)
25+
return userIDs.Values()
2826
}
2927

3028
func (actions ActionList) loadUsers(ctx context.Context) (map[int64]*user_model.User, error) {
@@ -48,13 +46,11 @@ func (actions ActionList) loadUsers(ctx context.Context) (map[int64]*user_model.
4846
}
4947

5048
func (actions ActionList) getRepoIDs() []int64 {
51-
repoIDs := make(map[int64]struct{}, len(actions))
49+
repoIDs := make(container.Set[int64], len(actions))
5250
for _, action := range actions {
53-
if _, ok := repoIDs[action.RepoID]; !ok {
54-
repoIDs[action.RepoID] = struct{}{}
55-
}
51+
repoIDs.Add(action.RepoID)
5652
}
57-
return container.KeysInt64(repoIDs)
53+
return repoIDs.Values()
5854
}
5955

6056
func (actions ActionList) loadRepositories(ctx context.Context) error {

models/activities/notification.go

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func CreateOrUpdateIssueNotifications(issueID, commentID, notificationAuthorID,
200200

201201
func createOrUpdateIssueNotifications(ctx context.Context, issueID, commentID, notificationAuthorID, receiverID int64) error {
202202
// init
203-
var toNotify map[int64]struct{}
203+
var toNotify container.Set[int64]
204204
notifications, err := getNotificationsByIssueID(ctx, issueID)
205205
if err != nil {
206206
return err
@@ -212,33 +212,27 @@ func createOrUpdateIssueNotifications(ctx context.Context, issueID, commentID, n
212212
}
213213

214214
if receiverID > 0 {
215-
toNotify = make(map[int64]struct{}, 1)
216-
toNotify[receiverID] = struct{}{}
215+
toNotify = make(container.Set[int64], 1)
216+
toNotify.Add(receiverID)
217217
} else {
218-
toNotify = make(map[int64]struct{}, 32)
218+
toNotify = make(container.Set[int64], 32)
219219
issueWatches, err := issues_model.GetIssueWatchersIDs(ctx, issueID, true)
220220
if err != nil {
221221
return err
222222
}
223-
for _, id := range issueWatches {
224-
toNotify[id] = struct{}{}
225-
}
223+
toNotify.AddMultiple(issueWatches...)
226224
if !(issue.IsPull && issues_model.HasWorkInProgressPrefix(issue.Title)) {
227225
repoWatches, err := repo_model.GetRepoWatchersIDs(ctx, issue.RepoID)
228226
if err != nil {
229227
return err
230228
}
231-
for _, id := range repoWatches {
232-
toNotify[id] = struct{}{}
233-
}
229+
toNotify.AddMultiple(repoWatches...)
234230
}
235231
issueParticipants, err := issue.GetParticipantIDsByIssue(ctx)
236232
if err != nil {
237233
return err
238234
}
239-
for _, id := range issueParticipants {
240-
toNotify[id] = struct{}{}
241-
}
235+
toNotify.AddMultiple(issueParticipants...)
242236

243237
// dont notify user who cause notification
244238
delete(toNotify, notificationAuthorID)
@@ -248,7 +242,7 @@ func createOrUpdateIssueNotifications(ctx context.Context, issueID, commentID, n
248242
return err
249243
}
250244
for _, id := range issueUnWatches {
251-
delete(toNotify, id)
245+
toNotify.Remove(id)
252246
}
253247
}
254248

@@ -499,16 +493,14 @@ func (nl NotificationList) LoadAttributes() error {
499493
}
500494

501495
func (nl NotificationList) getPendingRepoIDs() []int64 {
502-
ids := make(map[int64]struct{}, len(nl))
496+
ids := make(container.Set[int64], len(nl))
503497
for _, notification := range nl {
504498
if notification.Repository != nil {
505499
continue
506500
}
507-
if _, ok := ids[notification.RepoID]; !ok {
508-
ids[notification.RepoID] = struct{}{}
509-
}
501+
ids.Add(notification.RepoID)
510502
}
511-
return container.KeysInt64(ids)
503+
return ids.Values()
512504
}
513505

514506
// LoadRepos loads repositories from database
@@ -575,16 +567,14 @@ func (nl NotificationList) LoadRepos() (repo_model.RepositoryList, []int, error)
575567
}
576568

577569
func (nl NotificationList) getPendingIssueIDs() []int64 {
578-
ids := make(map[int64]struct{}, len(nl))
570+
ids := make(container.Set[int64], len(nl))
579571
for _, notification := range nl {
580572
if notification.Issue != nil {
581573
continue
582574
}
583-
if _, ok := ids[notification.IssueID]; !ok {
584-
ids[notification.IssueID] = struct{}{}
585-
}
575+
ids.Add(notification.IssueID)
586576
}
587-
return container.KeysInt64(ids)
577+
return ids.Values()
588578
}
589579

590580
// LoadIssues loads issues from database
@@ -661,16 +651,14 @@ func (nl NotificationList) Without(failures []int) NotificationList {
661651
}
662652

663653
func (nl NotificationList) getPendingCommentIDs() []int64 {
664-
ids := make(map[int64]struct{}, len(nl))
654+
ids := make(container.Set[int64], len(nl))
665655
for _, notification := range nl {
666656
if notification.CommentID == 0 || notification.Comment != nil {
667657
continue
668658
}
669-
if _, ok := ids[notification.CommentID]; !ok {
670-
ids[notification.CommentID] = struct{}{}
671-
}
659+
ids.Add(notification.CommentID)
672660
}
673-
return container.KeysInt64(ids)
661+
return ids.Values()
674662
}
675663

676664
// LoadComments loads comments from database

models/fixtures/oauth2_application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
name: "Test"
55
client_id: "da7da3ba-9a13-4167-856f-3899de0b0138"
66
client_secret: "$2a$10$UYRgUSgekzBp6hYe8pAdc.cgB4Gn06QRKsORUnIYTYQADs.YR/uvi" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
7-
redirect_uris: '["a"]'
7+
redirect_uris: '["a", "https://example.com/xyzzy"]'
88
created_unix: 1546869730
99
updated_unix: 1546869730

0 commit comments

Comments
 (0)