Skip to content

Commit 7e94a06

Browse files
authored
Merge branch 'main' into load-missing-diffs
2 parents 0d97cab + bb39359 commit 7e94a06

File tree

147 files changed

+2962
-1070
lines changed

Some content is hidden

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

147 files changed

+2962
-1070
lines changed

.drone.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ steps:
207207
commands:
208208
- git update-ref refs/heads/tag_test ${DRONE_COMMIT_SHA}
209209

210+
- name: fix-permissions
211+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
212+
commands:
213+
- chown -R gitea:gitea .
214+
210215
- name: unit-test
211-
image: golang:1.17
216+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
217+
user: gitea
212218
commands:
213219
- make unit-test-coverage test-check
214220
environment:
@@ -220,7 +226,8 @@ steps:
220226

221227
- name: unit-test-gogit
222228
pull: always
223-
image: golang:1.17
229+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
230+
user: gitea
224231
commands:
225232
- make unit-test-coverage test-check
226233
environment:
@@ -232,6 +239,7 @@ steps:
232239

233240
- name: test-mysql
234241
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
242+
user: gitea
235243
commands:
236244
- make test-mysql-migration integration-test-coverage
237245
environment:
@@ -246,6 +254,7 @@ steps:
246254

247255
- name: test-mysql8
248256
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
257+
user: gitea
249258
commands:
250259
- timeout -s ABRT 40m make test-mysql8-migration test-mysql8
251260
environment:
@@ -259,6 +268,7 @@ steps:
259268

260269
- name: test-mssql
261270
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
271+
user: gitea
262272
commands:
263273
- make test-mssql-migration test-mssql
264274
environment:
@@ -343,9 +353,15 @@ steps:
343353
exclude:
344354
- pull_request
345355

356+
- name: fix-permissions
357+
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
358+
commands:
359+
- chown -R gitea:gitea .
360+
346361
- name: build
347362
pull: always
348-
image: golang:1.17
363+
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
364+
user: gitea
349365
commands:
350366
- make backend
351367
environment:
@@ -355,6 +371,7 @@ steps:
355371

356372
- name: test-sqlite
357373
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
374+
user: gitea
358375
commands:
359376
- timeout -s ABRT 40m make test-sqlite-migration test-sqlite
360377
environment:
@@ -368,6 +385,7 @@ steps:
368385

369386
- name: test-pgsql
370387
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
388+
user: gitea
371389
commands:
372390
- timeout -s ABRT 40m make test-pgsql-migration test-pgsql
373391
environment:
@@ -534,7 +552,7 @@ steps:
534552

535553
- name: release-branch
536554
pull: always
537-
image: plugins/s3:1
555+
image: woodpeckerci/plugin-s3:latest
538556
settings:
539557
acl: public-read
540558
bucket: gitea-artifacts
@@ -555,7 +573,7 @@ steps:
555573
- push
556574

557575
- name: release-main
558-
image: plugins/s3:1
576+
image: woodpeckerci/plugin-s3:latest
559577
settings:
560578
acl: public-read
561579
bucket: gitea-artifacts
@@ -630,7 +648,7 @@ steps:
630648

631649
- name: release-tag
632650
pull: always
633-
image: plugins/s3:1
651+
image: woodpeckerci/plugin-s3:latest
634652
settings:
635653
acl: public-read
636654
bucket: gitea-artifacts

.github/ISSUE_TEMPLATE/bug-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ body:
2626
id: git-ver
2727
attributes:
2828
label: Git Version
29-
description: The version of git running on the server's systemm
29+
description: The version of git running on the server
3030
- type: input
3131
id: os-ver
3232
attributes:

.stylelintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ rules:
1313
rule-empty-line-before: null
1414
selector-pseudo-element-colon-notation: double
1515
shorthand-property-no-redundant-values: true
16+
no-invalid-position-at-import-rule: null

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ Patrick Schratz <[email protected]> (@pat-s)
4444
Janis Estelmann <[email protected]> (@KN4CK3R)
4545
Steven Kriegler <[email protected]> (@justusbunsi)
4646
Jimmy Praet <[email protected]> (@jpraet)
47+
Leon Hofmeister <[email protected]> (@delvh)

custom/conf/app.example.ini

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,10 @@ PATH =
10351035
;SHOW_USER_EMAIL = true
10361036
;;
10371037
;; Set the default theme for the Gitea install
1038-
;DEFAULT_THEME = gitea
1038+
;DEFAULT_THEME = auto
10391039
;;
10401040
;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
1041-
;THEMES = gitea,arc-green
1041+
;THEMES = auto,gitea,arc-green
10421042
;;
10431043
;; All available reactions users can choose on issues/prs and comments.
10441044
;; Values can be emoji alias (:smile:) or a unicode emoji.
@@ -1883,7 +1883,7 @@ PATH =
18831883
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18841884
;ENABLED = false
18851885
;RUN_AT_START = false
1886-
;NO_SUCCESS_NOTICE = f;alse
1886+
;NO_SUCCESS_NOTICE = false
18871887
;SCHEDULE = @every 72h
18881888

18891889
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1907,7 +1907,7 @@ PATH =
19071907
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19081908
;ENABLED = false
19091909
;RUN_AT_START = false
1910-
;NO_SUCCESS_NOTICE = f;alse
1910+
;NO_SUCCESS_NOTICE = false
19111911
;SCHEDULE = @every 72h
19121912

19131913
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2041,6 +2041,10 @@ PATH =
20412041
;ENABLED = false
20422042
;; If you want to add authorization, specify a token here
20432043
;TOKEN =
2044+
;; Enable issue by label metrics; default is false
2045+
;ENABLED_ISSUE_BY_LABEL = false
2046+
;; Enable issue by repository metrics; default is false
2047+
;ENABLED_ISSUE_BY_REPOSITORY = false
20442048

20452049
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20462050
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2081,6 +2085,15 @@ PATH =
20812085
;; Allow private addresses defined by RFC 1918, RFC 1122, RFC 4632 and RFC 4291 (false by default)
20822086
;ALLOW_LOCALNETWORKS = false
20832087

2088+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2089+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2090+
;[federation]
2091+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2092+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2093+
;;
2094+
;; Enable/Disable federation capabilities
2095+
; ENABLED = true
2096+
20842097
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20852098
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20862099
;; default storage for attachments, lfs and avatars

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
174174
- `FEED_PAGING_NUM`: **20**: Number of items that are displayed in home feed.
175175
- `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph.
176176
- `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment.
177-
- `DEFAULT_THEME`: **gitea**: \[gitea, arc-green\]: Set the default theme for the Gitea install.
177+
- `DEFAULT_THEME`: **auto**: \[auto, gitea, arc-green\]: Set the default theme for the Gitea install.
178178
- `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page.
179-
- `THEMES`: **gitea,arc-green**: All available themes. Allow users select personalized themes.
179+
- `THEMES`: **auto,gitea,arc-green**: All available themes. Allow users select personalized themes.
180180
regardless of the value of `DEFAULT_THEME`.
181181
- `THEME_COLOR_META_TAG`: **#6cc644**: Value of `theme-color` meta tag, used by Android >= 5.0. An invalid color like "none" or "disable" will have the default style. More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
182182
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
@@ -853,6 +853,8 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
853853
## Metrics (`metrics`)
854854

855855
- `ENABLED`: **false**: Enables /metrics endpoint for prometheus.
856+
- `ENABLED_ISSUE_BY_LABEL`: **false**: Enable issue by label metrics with format `gitea_issues_by_label{label="bug"} 2`.
857+
- `ENABLED_ISSUE_BY_REPOSITORY`: **false**: Enable issue by repository metrics with format `gitea_issues_by_repository{repository="org/repo"} 5`.
856858
- `TOKEN`: **\<empty\>**: You need to specify the token, if you want to include in the authorization the metrics . The same token need to be used in prometheus parameters `bearer_token` or `bearer_token_file`.
857859

858860
## API (`api`)
@@ -953,6 +955,10 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
953955
- `ALLOW_LOCALNETWORKS`: **false**: Allow private addresses defined by RFC 1918, RFC 1122, RFC 4632 and RFC 4291
954956
- `SKIP_TLS_VERIFY`: **false**: Allow skip tls verify
955957

958+
## Federation (`federation`)
959+
960+
- `ENABLED`: **true**: Enable/Disable federation capabilities
961+
956962
## Mirror (`mirror`)
957963

958964
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gite
321321

322322
## Customizing the look of Gitea
323323

324-
The default built-in themes are `gitea` (light) and `arc-green` (dark).
324+
The default built-in themes are `gitea` (light), `arc-green` (dark), and `auto` (chooses light or dark depending on operating system settings).
325325
The default theme can be changed via `DEFAULT_THEME` in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini`.
326326

327327
Gitea also has support for user themes, which means every user can select which theme should be used.

docs/content/doc/help/faq.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Use [Fail2Ban]({{< relref "doc/usage/fail2ban-setup.en-us.md" >}}) to monitor an
158158

159159
## How to add/use custom themes
160160

161-
Gitea supports two official themes right now, `gitea` and `arc-green` (`light` and `dark` respectively)
161+
Gitea supports three official themes right now, `gitea` (light), `arc-green` (dark), and `auto` (automatically switches between the previous two depending on operating system settings).
162162
To add your own theme, currently the only way is to provide a complete theme (not just color overrides)
163163

164164
As an example, let's say our theme is `arc-blue` (this is a real theme, and can be found [in this issue](https://github.com/go-gitea/gitea/issues/6011))

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.4
142+
xorm.io/xorm v1.2.5
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.4 h1:2MQV4wJt4kY6CYJsLxjCLzBen7+aqVxqDTIwfnR59g4=
1765-
xorm.io/xorm v1.2.4/go.mod h1:fTG8tSjk6O1BYxwuohZUK+S1glnRycsCF05L1qQyEU0=
1764+
xorm.io/xorm v1.2.5 h1:tqN7OhN8P9xi52qBb76I8m5maAJMz/SSbgK2RGPCPbo=
1765+
xorm.io/xorm v1.2.5/go.mod h1:fTG8tSjk6O1BYxwuohZUK+S1glnRycsCF05L1qQyEU0=

integrations/compare_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package integrations
66

77
import (
88
"net/http"
9+
"strings"
910
"testing"
1011

1112
"github.com/stretchr/testify/assert"
@@ -21,4 +22,8 @@ func TestCompareTag(t *testing.T) {
2122
selection := htmlDoc.doc.Find(".choose.branch .filter.dropdown")
2223
// A dropdown for both base and head.
2324
assert.Lenf(t, selection.Nodes, 2, "The template has changed")
25+
26+
req = NewRequest(t, "GET", "/user2/repo1/compare/invalid")
27+
resp = session.MakeRequest(t, req, http.StatusNotFound)
28+
assert.False(t, strings.Contains(resp.Body.String(), "/assets/img/500.png"), "expect 404 page not 500")
2429
}

integrations/rename_branch_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"testing"
10+
11+
"code.gitea.io/gitea/models"
12+
"code.gitea.io/gitea/models/db"
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestRenameBranch(t *testing.T) {
17+
// get branch setting page
18+
session := loginUser(t, "user2")
19+
req := NewRequest(t, "GET", "/user2/repo1/settings/branches")
20+
resp := session.MakeRequest(t, req, http.StatusOK)
21+
htmlDoc := NewHTMLParser(t, resp.Body)
22+
23+
postData := map[string]string{
24+
"_csrf": htmlDoc.GetCSRF(),
25+
"from": "master",
26+
"to": "main",
27+
}
28+
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/rename_branch", postData)
29+
session.MakeRequest(t, req, http.StatusFound)
30+
31+
// check new branch link
32+
req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/main/README.md", postData)
33+
session.MakeRequest(t, req, http.StatusOK)
34+
35+
// check old branch link
36+
req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/master/README.md", postData)
37+
resp = session.MakeRequest(t, req, http.StatusFound)
38+
location := resp.HeaderMap.Get("Location")
39+
assert.Equal(t, "/user2/repo1/src/branch/main/README.md", location)
40+
41+
// check db
42+
repo1 := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
43+
assert.Equal(t, "main", repo1.DefaultBranch)
44+
}

integrations/user_avatar_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"mime/multipart"
1212
"net/http"
1313
"net/url"
14-
"strings"
1514
"testing"
1615

1716
"code.gitea.io/gitea/models"
@@ -75,14 +74,8 @@ func TestUserAvatar(t *testing.T) {
7574
user2 = db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo3, is an org
7675

7776
req = NewRequest(t, "GET", user2.AvatarLink())
78-
resp := session.MakeRequest(t, req, http.StatusFound)
79-
location := resp.Header().Get("Location")
80-
if !strings.HasPrefix(location, "/avatars") {
81-
assert.Fail(t, "Avatar location is not local: %s", location)
82-
}
83-
req = NewRequest(t, "GET", location)
84-
session.MakeRequest(t, req, http.StatusOK)
77+
_ = session.MakeRequest(t, req, http.StatusOK)
8578

86-
// Can't test if the response matches because the image is regened on upload but checking that this at least doesn't give a 404 should be enough.
79+
// Can't test if the response matches because the image is re-generated on upload but checking that this at least doesn't give a 404 should be enough.
8780
})
8881
}

models/access.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ func (repo *Repository) refreshCollaboratorAccesses(e db.Engine, accessMap map[i
230230
return fmt.Errorf("getCollaborations: %v", err)
231231
}
232232
for _, c := range collaborators {
233+
if c.User.IsGhost() {
234+
continue
235+
}
233236
updateUserAccess(accessMap, c.User, c.Collaboration.Mode)
234237
}
235238
return nil

models/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
107107
notices := make([]*Notice, 0, pageSize)
108108
return notices, db.GetEngine(db.DefaultContext).
109109
Limit(pageSize, (page-1)*pageSize).
110-
Desc("id").
110+
Desc("created_unix").
111111
Find(&notices)
112112
}
113113

0 commit comments

Comments
 (0)