Skip to content

Commit d94b4bf

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-15178-provide-aliases-for-submodules
2 parents c8463b4 + 5c80ecc commit d94b4bf

File tree

179 files changed

+3350
-942
lines changed

Some content is hidden

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

179 files changed

+3350
-942
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Kyle Dumont <[email protected]> (@kdumontnu)
4343
Patrick Schratz <[email protected]> (@pat-s)
4444
Janis Estelmann <[email protected]> (@KN4CK3R)
4545
Steven Kriegler <[email protected]> (@justusbunsi)
46+
Jimmy Praet <[email protected]> (@jpraet)

cmd/convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func runConvert(ctx *cli.Context) error {
2727
return err
2828
}
2929

30-
log.Trace("AppPath: %s", setting.AppPath)
31-
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
32-
log.Trace("Custom path: %s", setting.CustomPath)
33-
log.Trace("Log path: %s", setting.LogRootPath)
30+
log.Info("AppPath: %s", setting.AppPath)
31+
log.Info("AppWorkPath: %s", setting.AppWorkPath)
32+
log.Info("Custom path: %s", setting.CustomPath)
33+
log.Info("Log path: %s", setting.LogRootPath)
3434
setting.InitDBConfig()
3535

3636
if !setting.Database.UseMySQL {

cmd/dump_repo.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var CmdDumpRepository = cli.Command{
6969
cli.StringFlag{
7070
Name: "units",
7171
Value: "",
72-
Usage: `Which items will be migrated, one or more units should be separated as comma.
72+
Usage: `Which items will be migrated, one or more units should be separated as comma.
7373
wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
7474
},
7575
},
@@ -80,10 +80,10 @@ func runDumpRepository(ctx *cli.Context) error {
8080
return err
8181
}
8282

83-
log.Trace("AppPath: %s", setting.AppPath)
84-
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
85-
log.Trace("Custom path: %s", setting.CustomPath)
86-
log.Trace("Log path: %s", setting.LogRootPath)
83+
log.Info("AppPath: %s", setting.AppPath)
84+
log.Info("AppWorkPath: %s", setting.AppWorkPath)
85+
log.Info("Custom path: %s", setting.CustomPath)
86+
log.Info("Log path: %s", setting.LogRootPath)
8787
setting.InitDBConfig()
8888

8989
var (

cmd/hook.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,16 @@ Gitea or set your environment appropriately.`, "")
221221
total++
222222
lastline++
223223

224-
// If the ref is a branch, check if it's protected
225-
if strings.HasPrefix(refFullName, git.BranchPrefix) {
224+
// If the ref is a branch or tag, check if it's protected
225+
if strings.HasPrefix(refFullName, git.BranchPrefix) || strings.HasPrefix(refFullName, git.TagPrefix) {
226226
oldCommitIDs[count] = oldCommitID
227227
newCommitIDs[count] = newCommitID
228228
refFullNames[count] = refFullName
229229
count++
230230
fmt.Fprintf(out, "*")
231231

232232
if count >= hookBatchSize {
233-
fmt.Fprintf(out, " Checking %d branches\n", count)
233+
fmt.Fprintf(out, " Checking %d references\n", count)
234234

235235
hookOptions.OldCommitIDs = oldCommitIDs
236236
hookOptions.NewCommitIDs = newCommitIDs
@@ -261,7 +261,7 @@ Gitea or set your environment appropriately.`, "")
261261
hookOptions.NewCommitIDs = newCommitIDs[:count]
262262
hookOptions.RefFullNames = refFullNames[:count]
263263

264-
fmt.Fprintf(out, " Checking %d branches\n", count)
264+
fmt.Fprintf(out, " Checking %d references\n", count)
265265

266266
statusCode, msg := private.HookPreReceive(username, reponame, hookOptions)
267267
switch statusCode {

cmd/migrate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ func runMigrate(ctx *cli.Context) error {
2828
return err
2929
}
3030

31-
log.Trace("AppPath: %s", setting.AppPath)
32-
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
33-
log.Trace("Custom path: %s", setting.CustomPath)
34-
log.Trace("Log path: %s", setting.LogRootPath)
31+
log.Info("AppPath: %s", setting.AppPath)
32+
log.Info("AppWorkPath: %s", setting.AppWorkPath)
33+
log.Info("Custom path: %s", setting.CustomPath)
34+
log.Info("Log path: %s", setting.LogRootPath)
3535
setting.InitDBConfig()
3636

3737
if err := models.NewEngine(context.Background(), migrations.Migrate); err != nil {

cmd/migrate_storage.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ func runMigrateStorage(ctx *cli.Context) error {
110110
return err
111111
}
112112

113-
log.Trace("AppPath: %s", setting.AppPath)
114-
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
115-
log.Trace("Custom path: %s", setting.CustomPath)
116-
log.Trace("Log path: %s", setting.LogRootPath)
113+
log.Info("AppPath: %s", setting.AppPath)
114+
log.Info("AppWorkPath: %s", setting.AppWorkPath)
115+
log.Info("Custom path: %s", setting.CustomPath)
116+
log.Info("Log path: %s", setting.LogRootPath)
117117
setting.InitDBConfig()
118118

119119
if err := models.NewEngine(context.Background(), migrations.Migrate); err != nil {

cmd/web.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ and it takes care of all the other things for you`,
4747
Value: setting.PIDFile,
4848
Usage: "Custom pid file path",
4949
},
50+
cli.BoolFlag{
51+
Name: "quiet, q",
52+
Usage: "Only display Fatal logging errors until logging is set-up",
53+
},
54+
cli.BoolFlag{
55+
Name: "verbose",
56+
Usage: "Set initial logging to TRACE level until logging is properly set-up",
57+
},
5058
},
5159
}
5260

@@ -71,6 +79,14 @@ func runHTTPRedirector() {
7179
}
7280

7381
func runWeb(ctx *cli.Context) error {
82+
if ctx.Bool("verbose") {
83+
_ = log.DelLogger("console")
84+
log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "trace", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
85+
} else if ctx.Bool("quiet") {
86+
_ = log.DelLogger("console")
87+
log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "fatal", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
88+
}
89+
7490
managerCtx, cancel := context.WithCancel(context.Background())
7591
graceful.InitManager(managerCtx)
7692
defer cancel()

contrib/pr/checkout.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"time"
2727

2828
"code.gitea.io/gitea/models"
29+
gitea_git "code.gitea.io/gitea/modules/git"
2930
"code.gitea.io/gitea/modules/markup"
3031
"code.gitea.io/gitea/modules/markup/external"
3132
"code.gitea.io/gitea/modules/setting"
@@ -79,7 +80,7 @@ func runPR() {
7980
setting.RunUser = curUser.Username
8081

8182
log.Printf("[PR] Loading fixtures data ...\n")
82-
setting.CheckLFSVersion()
83+
gitea_git.CheckLFSVersion()
8384
//models.LoadConfigs()
8485
/*
8586
setting.Database.Type = "sqlite3"

custom/conf/app.example.ini

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,18 @@ PATH =
661661
;DEFAULT_ALLOW_CREATE_ORGANIZATION = true
662662
;;
663663
;; Either "public", "limited" or "private", default is "public"
664-
;; Limited is for signed user only
665-
;; Private is only for member of the organization
666-
;; Public is for everyone
664+
;; Limited is for users visible only to signed users
665+
;; Private is for users visible only to members of their organizations
666+
;; Public is for users visible for everyone
667+
;DEFAULT_USER_VISIBILITY = public
668+
;;
669+
;; Set whitch visibibilty modes a user can have
670+
;ALLOWED_USER_VISIBILITY_MODES = public,limited,private
671+
;;
672+
;; Either "public", "limited" or "private", default is "public"
673+
;; Limited is for organizations visible only to signed users
674+
;; Private is for organizations visible only to members of the organization
675+
;; Public is for organizations visible to everyone
667676
;DEFAULT_ORG_VISIBILITY = public
668677
;;
669678
;; Default value for DefaultOrgMemberVisible
@@ -715,6 +724,8 @@ PATH =
715724
;;
716725
;; Minimum amount of time a user must exist before comments are kept when the user is deleted.
717726
;USER_DELETE_WITH_COMMENTS_MAX_TIME = 0
727+
;; Valid site url schemes for user profiles
728+
;VALID_SITE_URL_SCHEMES=http,https
718729

719730

720731
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,16 @@ relation to port exhaustion.
512512
- `SHOW_MILESTONES_DASHBOARD_PAGE`: **true** Enable this to show the milestones dashboard page - a view of all the user's milestones
513513
- `AUTO_WATCH_NEW_REPOS`: **true**: Enable this to let all organisation users watch new repos when they are created
514514
- `AUTO_WATCH_ON_CHANGES`: **false**: Enable this to make users watch a repository after their first commit to it
515+
- `DEFAULT_USER_VISIBILITY`: **public**: Set default visibility mode for users, either "public", "limited" or "private".
516+
- `ALLOWED_USER_VISIBILITY_MODES`: **public,limited,private**: Set whitch visibibilty modes a user can have
515517
- `DEFAULT_ORG_VISIBILITY`: **public**: Set default visibility mode for organisations, either "public", "limited" or "private".
516518
- `DEFAULT_ORG_MEMBER_VISIBLE`: **false** True will make the membership of the users visible when added to the organisation.
517519
- `ALLOW_ONLY_INTERNAL_REGISTRATION`: **false** Set to true to force registration only via gitea.
518520
- `ALLOW_ONLY_EXTERNAL_REGISTRATION`: **false** Set to true to force registration only using third-party services.
519521
- `NO_REPLY_ADDRESS`: **noreply.DOMAIN** Value for the domain part of the user's email address in the git log if user has set KeepEmailPrivate to true. DOMAIN resolves to the value in server.DOMAIN.
520522
The user's email will be replaced with a concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
521523
- `USER_DELETE_WITH_COMMENTS_MAX_TIME`: **0** Minimum amount of time a user must exist before comments are kept when the user is deleted.
524+
- `VALID_SITE_URL_SCHEMES`: **http, https**: Valid site url schemes for user profiles
522525

523526
### Service - Expore (`service.explore`)
524527

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
date: "2021-05-14T00:00:00-00:00"
3+
title: "Protected tags"
4+
slug: "protected-tags"
5+
weight: 45
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "advanced"
11+
name: "Protected tags"
12+
weight: 45
13+
identifier: "protected-tags"
14+
---
15+
16+
# Protected tags
17+
18+
Protected tags allow control over who has permission to create or update git tags. Each rule allows you to match either an individual tag name, or use an appropriate pattern to control multiple tags at once.
19+
20+
**Table of Contents**
21+
22+
{{< toc >}}
23+
24+
## Setting up protected tags
25+
26+
To protect a tag, you need to follow these steps:
27+
28+
1. Go to the repository’s **Settings** > **Tags** page.
29+
1. Type a pattern to match a name. You can use a single name, a [glob pattern](https://pkg.go.dev/github.com/gobwas/glob#Compile) or a regular expression.
30+
1. Choose the allowed users and/or teams. If you leave these fields empty noone is allowed to create or modify this tag.
31+
1. Select **Save** to save the configuration.
32+
33+
## Pattern protected tags
34+
35+
The pattern uses [glob](https://pkg.go.dev/github.com/gobwas/glob#Compile) or regular expressions to match a tag name. For regular expressions you need to enclose the pattern in slashes.
36+
37+
Examples:
38+
39+
| Type | Pattern Protected Tag | Possible Matching Tags |
40+
| ----- | ------------------------ | --------------------------------------- |
41+
| Glob | `v*` | `v`, `v-1`, `version2` |
42+
| Glob | `v[0-9]` | `v0`, `v1` up to `v9` |
43+
| Glob | `*-release` | `2.1-release`, `final-release` |
44+
| Glob | `gitea` | only `gitea` |
45+
| Glob | `*gitea*` | `gitea`, `2.1-gitea`, `1_gitea-release` |
46+
| Glob | `{v,rel}-*` | `v-`, `v-1`, `v-final`, `rel-`, `rel-x` |
47+
| Glob | `*` | matches all possible tag names |
48+
| Regex | `/\Av/` | `v`, `v-1`, `version2` |
49+
| Regex | `/\Av[0-9]\z/` | `v0`, `v1` up to `v9` |
50+
| Regex | `/\Av\d+\.\d+\.\d+\z/` | `v1.0.17`, `v2.1.0` |
51+
| Regex | `/\Av\d+(\.\d+){0,2}\z/` | `v1`, `v2.1`, `v1.2.34` |
52+
| Regex | `/-release\z/` | `2.1-release`, `final-release` |
53+
| Regex | `/gitea/` | `gitea`, `2.1-gitea`, `1_gitea-release` |
54+
| Regex | `/\Agitea\z/` | only `gitea` |
55+
| Regex | `/^gitea$/` | only `gitea` |
56+
| Regex | `/\A(v\|rel)-/` | `v-`, `v-1`, `v-final`, `rel-`, `rel-x` |
57+
| Regex | `/.+/` | matches all possible tag names |

docs/content/doc/usage/command-line.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Starts the server:
4646
- `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
4747
- `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file.
4848
- `--pid path`, `-P path`: Pidfile path. Optional.
49+
- `--quiet`, `-q`: Only emit Fatal logs on the console for logs emitted before logging set up.
50+
- `--verbose`: Emit tracing logs on the console for logs emitted before logging is set-up.
4951
- Examples:
5052
- `gitea web`
5153
- `gitea web --port 80`

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
221221
```xml
222222
<?xml version="1.0" encoding="UTF-8"?>
223223
<configuration>
224+
<system.web>
225+
<httpRuntime requestPathInvalidCharacters="" />
226+
</system.web>
224227
<system.webServer>
225228
<security>
226229
<requestFiltering>

integrations/api_pull_review_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/models"
1313
api "code.gitea.io/gitea/modules/structs"
14+
jsoniter "github.com/json-iterator/go"
1415
"github.com/stretchr/testify/assert"
1516
)
1617

@@ -139,6 +140,59 @@ func TestAPIPullReview(t *testing.T) {
139140
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)
140141
resp = session.MakeRequest(t, req, http.StatusNoContent)
141142

143+
// test CreatePullReview Comment without body but with comments
144+
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
145+
// Body: "",
146+
Event: "COMMENT",
147+
Comments: []api.CreatePullReviewComment{{
148+
Path: "README.md",
149+
Body: "first new line",
150+
OldLineNum: 0,
151+
NewLineNum: 1,
152+
}, {
153+
Path: "README.md",
154+
Body: "first old line",
155+
OldLineNum: 1,
156+
NewLineNum: 0,
157+
},
158+
},
159+
})
160+
var commentReview api.PullReview
161+
162+
resp = session.MakeRequest(t, req, http.StatusOK)
163+
DecodeJSON(t, resp, &commentReview)
164+
assert.EqualValues(t, "COMMENT", commentReview.State)
165+
assert.EqualValues(t, 2, commentReview.CodeCommentsCount)
166+
assert.EqualValues(t, "", commentReview.Body)
167+
assert.EqualValues(t, false, commentReview.Dismissed)
168+
169+
// test CreatePullReview Comment with body but without comments
170+
commentBody := "This is a body of the comment."
171+
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
172+
Body: commentBody,
173+
Event: "COMMENT",
174+
Comments: []api.CreatePullReviewComment{},
175+
})
176+
177+
resp = session.MakeRequest(t, req, http.StatusOK)
178+
DecodeJSON(t, resp, &commentReview)
179+
assert.EqualValues(t, "COMMENT", commentReview.State)
180+
assert.EqualValues(t, 0, commentReview.CodeCommentsCount)
181+
assert.EqualValues(t, commentBody, commentReview.Body)
182+
assert.EqualValues(t, false, commentReview.Dismissed)
183+
184+
// test CreatePullReview Comment without body and no comments
185+
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
186+
Body: "",
187+
Event: "COMMENT",
188+
Comments: []api.CreatePullReviewComment{},
189+
})
190+
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
191+
errMap := make(map[string]interface{})
192+
json := jsoniter.ConfigCompatibleWithStandardLibrary
193+
json.Unmarshal(resp.Body.Bytes(), &errMap)
194+
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
195+
142196
// test get review requests
143197
// to make it simple, use same api with get review
144198
pullIssue12 := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 12}).(*models.Issue)

integrations/api_user_heatmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestUserHeatmap(t *testing.T) {
2626
var heatmap []*models.UserHeatmapData
2727
DecodeJSON(t, resp, &heatmap)
2828
var dummyheatmap []*models.UserHeatmapData
29-
dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1603152000, Contributions: 1})
29+
dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
3030

3131
assert.Equal(t, dummyheatmap, heatmap)
3232
}

integrations/api_user_search_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,34 @@ func TestAPIUserSearchNotLoggedIn(t *testing.T) {
5959
}
6060
}
6161
}
62+
63+
func TestAPIUserSearchAdminLoggedInUserHidden(t *testing.T) {
64+
defer prepareTestEnv(t)()
65+
adminUsername := "user1"
66+
session := loginUser(t, adminUsername)
67+
token := getTokenForLoggedInUser(t, session)
68+
query := "user31"
69+
req := NewRequestf(t, "GET", "/api/v1/users/search?token=%s&q=%s", token, query)
70+
req.SetBasicAuth(token, "x-oauth-basic")
71+
resp := session.MakeRequest(t, req, http.StatusOK)
72+
73+
var results SearchResults
74+
DecodeJSON(t, resp, &results)
75+
assert.NotEmpty(t, results.Data)
76+
for _, user := range results.Data {
77+
assert.Contains(t, user.UserName, query)
78+
assert.NotEmpty(t, user.Email)
79+
assert.EqualValues(t, "private", user.Visibility)
80+
}
81+
}
82+
83+
func TestAPIUserSearchNotLoggedInUserHidden(t *testing.T) {
84+
defer prepareTestEnv(t)()
85+
query := "user31"
86+
req := NewRequestf(t, "GET", "/api/v1/users/search?q=%s", query)
87+
resp := MakeRequest(t, req, http.StatusOK)
88+
89+
var results SearchResults
90+
DecodeJSON(t, resp, &results)
91+
assert.Empty(t, results.Data)
92+
}

0 commit comments

Comments
 (0)