Skip to content

Commit a442905

Browse files
authored
Merge branch 'main' into load-templates-once-and-better-reload
2 parents 0ff8921 + 532c223 commit a442905

File tree

251 files changed

+3617
-5889
lines changed

Some content is hidden

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

251 files changed

+3617
-5889
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ clean:
242242

243243
.PHONY: fmt
244244
fmt:
245-
@echo "Running gitea-fmt (with gofumpt)..."
246245
@MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
246+
$(eval TEMPLATES := $(wildcard templates/**/*.tmpl))
247+
@# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
248+
@$(SED_INPLACE) -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES)
247249

248250
.PHONY: vet
249251
vet:
@@ -288,13 +290,19 @@ errcheck:
288290

289291
.PHONY: fmt-check
290292
fmt-check:
291-
# get all go files and run gitea-fmt (with gofmt) on them
293+
@# get all go files and run gitea-fmt (with gofmt) on them
292294
@diff=$$(MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -l '{file-list}'); \
293295
if [ -n "$$diff" ]; then \
294296
echo "Please run 'make fmt' and commit the result:"; \
295297
echo "$${diff}"; \
296298
exit 1; \
297299
fi
300+
@diff2=$$(git diff templates); \
301+
if [ -n "$$diff2" ]; then \
302+
echo "Please run 'make fmt' and commit the result:"; \
303+
echo "$${diff2}"; \
304+
exit 1; \
305+
fi
298306

299307
.PHONY: checks
300308
checks: checks-frontend checks-backend

build/gitea-format-imports.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

cmd/admin.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import (
1313
"strings"
1414
"text/tabwriter"
1515

16-
"code.gitea.io/gitea/models"
1716
asymkey_model "code.gitea.io/gitea/models/asymkey"
18-
"code.gitea.io/gitea/models/auth"
17+
auth_model "code.gitea.io/gitea/models/auth"
1918
"code.gitea.io/gitea/models/db"
2019
repo_model "code.gitea.io/gitea/models/repo"
2120
user_model "code.gitea.io/gitea/models/user"
@@ -593,12 +592,12 @@ func runCreateUser(c *cli.Context) error {
593592
}
594593

595594
if c.Bool("access-token") {
596-
t := &models.AccessToken{
595+
t := &auth_model.AccessToken{
597596
Name: "gitea-admin",
598597
UID: u.ID,
599598
}
600599

601-
if err := models.NewAccessToken(t); err != nil {
600+
if err := auth_model.NewAccessToken(t); err != nil {
602601
return err
603602
}
604603

@@ -700,12 +699,12 @@ func runGenerateAccessToken(c *cli.Context) error {
700699
return err
701700
}
702701

703-
t := &models.AccessToken{
702+
t := &auth_model.AccessToken{
704703
Name: c.String("token-name"),
705704
UID: user.ID,
706705
}
707706

708-
if err := models.NewAccessToken(t); err != nil {
707+
if err := auth_model.NewAccessToken(t); err != nil {
709708
return err
710709
}
711710

@@ -779,9 +778,9 @@ func runRepoSyncReleases(_ *cli.Context) error {
779778
}
780779

781780
func getReleaseCount(id int64) (int64, error) {
782-
return models.GetReleaseCountByRepoID(
781+
return repo_model.GetReleaseCountByRepoID(
783782
id,
784-
models.FindReleasesOptions{
783+
repo_model.FindReleasesOptions{
785784
IncludeTags: true,
786785
},
787786
)
@@ -844,8 +843,8 @@ func runAddOauth(c *cli.Context) error {
844843
return err
845844
}
846845

847-
return auth.CreateSource(&auth.Source{
848-
Type: auth.OAuth2,
846+
return auth_model.CreateSource(&auth_model.Source{
847+
Type: auth_model.OAuth2,
849848
Name: c.String("name"),
850849
IsActive: true,
851850
Cfg: parseOAuth2Config(c),
@@ -864,7 +863,7 @@ func runUpdateOauth(c *cli.Context) error {
864863
return err
865864
}
866865

867-
source, err := auth.GetSourceByID(c.Int64("id"))
866+
source, err := auth_model.GetSourceByID(c.Int64("id"))
868867
if err != nil {
869868
return err
870869
}
@@ -944,7 +943,7 @@ func runUpdateOauth(c *cli.Context) error {
944943
oAuth2Config.CustomURLMapping = customURLMapping
945944
source.Cfg = oAuth2Config
946945

947-
return auth.UpdateSource(source)
946+
return auth_model.UpdateSource(source)
948947
}
949948

950949
func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
@@ -1015,8 +1014,8 @@ func runAddSMTP(c *cli.Context) error {
10151014
smtpConfig.Auth = "PLAIN"
10161015
}
10171016

1018-
return auth.CreateSource(&auth.Source{
1019-
Type: auth.SMTP,
1017+
return auth_model.CreateSource(&auth_model.Source{
1018+
Type: auth_model.SMTP,
10201019
Name: c.String("name"),
10211020
IsActive: active,
10221021
Cfg: &smtpConfig,
@@ -1035,7 +1034,7 @@ func runUpdateSMTP(c *cli.Context) error {
10351034
return err
10361035
}
10371036

1038-
source, err := auth.GetSourceByID(c.Int64("id"))
1037+
source, err := auth_model.GetSourceByID(c.Int64("id"))
10391038
if err != nil {
10401039
return err
10411040
}
@@ -1056,7 +1055,7 @@ func runUpdateSMTP(c *cli.Context) error {
10561055

10571056
source.Cfg = smtpConfig
10581057

1059-
return auth.UpdateSource(source)
1058+
return auth_model.UpdateSource(source)
10601059
}
10611060

10621061
func runListAuth(c *cli.Context) error {
@@ -1067,7 +1066,7 @@ func runListAuth(c *cli.Context) error {
10671066
return err
10681067
}
10691068

1070-
authSources, err := auth.Sources()
1069+
authSources, err := auth_model.Sources()
10711070
if err != nil {
10721071
return err
10731072
}
@@ -1105,7 +1104,7 @@ func runDeleteAuth(c *cli.Context) error {
11051104
return err
11061105
}
11071106

1108-
source, err := auth.GetSourceByID(c.Int64("id"))
1107+
source, err := auth_model.GetSourceByID(c.Int64("id"))
11091108
if err != nil {
11101109
return err
11111110
}

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,10 @@ ROUTER = console
11641164
;;
11651165
;; Whether to enable a Service Worker to cache frontend assets
11661166
;USE_SERVICE_WORKER = false
1167+
;;
1168+
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
1169+
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
1170+
;ONLY_SHOW_RELEVANT_REPOS = false
11671171

11681172
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11691173
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ The following configuration set `Content-Type: application/vnd.android.package-a
194194
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
195195
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
196196
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
197+
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
198+
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
197199

198200
### UI - Admin (`ui.admin`)
199201

integrations/api_notification_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"code.gitea.io/gitea/models"
12+
activities_model "code.gitea.io/gitea/models/activities"
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
"code.gitea.io/gitea/models/unittest"
1515
user_model "code.gitea.io/gitea/models/user"
@@ -23,7 +23,7 @@ func TestAPINotification(t *testing.T) {
2323

2424
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
2525
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
26-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
26+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
2727
assert.NoError(t, thread5.LoadAttributes())
2828
session := loginUser(t, user2.Name)
2929
token := getTokenForLoggedInUser(t, session)
@@ -126,9 +126,9 @@ func TestAPINotification(t *testing.T) {
126126
req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
127127
session.MakeRequest(t, req, http.StatusResetContent)
128128

129-
assert.Equal(t, models.NotificationStatusUnread, thread5.Status)
130-
thread5 = unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
131-
assert.Equal(t, models.NotificationStatusRead, thread5.Status)
129+
assert.Equal(t, activities_model.NotificationStatusUnread, thread5.Status)
130+
thread5 = unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
131+
assert.Equal(t, activities_model.NotificationStatusRead, thread5.Status)
132132

133133
// -- check notifications --
134134
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token))
@@ -141,7 +141,7 @@ func TestAPINotificationPUT(t *testing.T) {
141141
defer prepareTestEnv(t)()
142142

143143
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
144-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
144+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
145145
assert.NoError(t, thread5.LoadAttributes())
146146
session := loginUser(t, user2.Name)
147147
token := getTokenForLoggedInUser(t, session)

integrations/api_releases_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"code.gitea.io/gitea/models"
1413
repo_model "code.gitea.io/gitea/models/repo"
1514
"code.gitea.io/gitea/models/unittest"
1615
user_model "code.gitea.io/gitea/models/user"
@@ -84,7 +83,7 @@ func createNewReleaseUsingAPI(t *testing.T, session *TestSession, token string,
8483

8584
var newRelease api.Release
8685
DecodeJSON(t, resp, &newRelease)
87-
rel := &models.Release{
86+
rel := &repo_model.Release{
8887
ID: newRelease.ID,
8988
TagName: newRelease.TagName,
9089
Title: newRelease.Title,
@@ -138,7 +137,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) {
138137
resp = session.MakeRequest(t, req, http.StatusOK)
139138

140139
DecodeJSON(t, resp, &newRelease)
141-
rel := &models.Release{
140+
rel := &repo_model.Release{
142141
ID: newRelease.ID,
143142
TagName: newRelease.TagName,
144143
Title: newRelease.Title,

integrations/api_token_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/http"
99
"testing"
1010

11-
"code.gitea.io/gitea/models"
11+
auth_model "code.gitea.io/gitea/models/auth"
1212
"code.gitea.io/gitea/models/unittest"
1313
user_model "code.gitea.io/gitea/models/user"
1414
api "code.gitea.io/gitea/modules/structs"
@@ -27,7 +27,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
2727

2828
var newAccessToken api.AccessToken
2929
DecodeJSON(t, resp, &newAccessToken)
30-
unittest.AssertExistsAndLoadBean(t, &models.AccessToken{
30+
unittest.AssertExistsAndLoadBean(t, &auth_model.AccessToken{
3131
ID: newAccessToken.ID,
3232
Name: newAccessToken.Name,
3333
Token: newAccessToken.Token,
@@ -38,7 +38,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
3838
req = AddBasicAuthHeader(req, user.Name)
3939
MakeRequest(t, req, http.StatusNoContent)
4040

41-
unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
41+
unittest.AssertNotExistsBean(t, &auth_model.AccessToken{ID: newAccessToken.ID})
4242

4343
req = NewRequestWithJSON(t, "POST", "/api/v1/users/user1/tokens", map[string]string{
4444
"name": "test-key-2",
@@ -51,7 +51,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
5151
req = AddBasicAuthHeader(req, user.Name)
5252
MakeRequest(t, req, http.StatusNoContent)
5353

54-
unittest.AssertNotExistsBean(t, &models.AccessToken{ID: newAccessToken.ID})
54+
unittest.AssertNotExistsBean(t, &auth_model.AccessToken{ID: newAccessToken.ID})
5555
}
5656

5757
// TestAPIDeleteMissingToken ensures that error is thrown when token not found

integrations/api_user_heatmap_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"code.gitea.io/gitea/models"
13+
activities_model "code.gitea.io/gitea/models/activities"
1414
"code.gitea.io/gitea/modules/timeutil"
1515

1616
"github.com/stretchr/testify/assert"
@@ -29,10 +29,10 @@ func TestUserHeatmap(t *testing.T) {
2929
urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap?token=%s", normalUsername, token)
3030
req := NewRequest(t, "GET", urlStr)
3131
resp := MakeRequest(t, req, http.StatusOK)
32-
var heatmap []*models.UserHeatmapData
32+
var heatmap []*activities_model.UserHeatmapData
3333
DecodeJSON(t, resp, &heatmap)
34-
var dummyheatmap []*models.UserHeatmapData
35-
dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
34+
var dummyheatmap []*activities_model.UserHeatmapData
35+
dummyheatmap = append(dummyheatmap, &activities_model.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
3636

3737
assert.Equal(t, dummyheatmap, heatmap)
3838
}

integrations/eventsource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"code.gitea.io/gitea/models"
13+
activities_model "code.gitea.io/gitea/models/activities"
1414
repo_model "code.gitea.io/gitea/models/repo"
1515
"code.gitea.io/gitea/models/unittest"
1616
user_model "code.gitea.io/gitea/models/user"
@@ -42,7 +42,7 @@ func TestEventSourceManagerRun(t *testing.T) {
4242
if !ok {
4343
return false
4444
}
45-
data, ok := event.Data.(models.UserIDCount)
45+
data, ok := event.Data.(activities_model.UserIDCount)
4646
if !ok {
4747
return false
4848
}
@@ -55,7 +55,7 @@ func TestEventSourceManagerRun(t *testing.T) {
5555

5656
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
5757
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
58-
thread5 := unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5})
58+
thread5 := unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5})
5959
assert.NoError(t, thread5.LoadAttributes())
6060
session := loginUser(t, user2.Name)
6161
token := getTokenForLoggedInUser(t, session)

0 commit comments

Comments
 (0)