Skip to content

Commit a86a45a

Browse files
authored
Merge branch 'main' into refactor-webhook
2 parents 68be93f + 0b27b93 commit a86a45a

Some content is hidden

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

67 files changed

+864
-221
lines changed

Diff for: MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Kyle Dumont <kdumontnu@gmail.com> (@kdumontnu)
4343
Patrick Schratz <patrick.schratz@gmail.com> (@pat-s)
4444
Janis Estelmann <admin@oldschoolhack.me> (@KN4CK3R)
4545
Steven Kriegler <sk.bunsenbrenner@gmail.com> (@justusbunsi)
46+
Jimmy Praet <jimmy.praet@telenet.be> (@jpraet)

Diff for: cmd/convert.go

+4-4
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 {

Diff for: cmd/dump_repo.go

+5-5
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 (

Diff for: cmd/migrate.go

+4-4
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 {

Diff for: cmd/migrate_storage.go

+4-4
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 {

Diff for: cmd/web.go

+16
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()

Diff for: contrib/pr/checkout.go

+2-1
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"

Diff for: custom/conf/app.example.ini

+12-3
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,18 @@ PATH =
651651
;DEFAULT_ALLOW_CREATE_ORGANIZATION = true
652652
;;
653653
;; Either "public", "limited" or "private", default is "public"
654-
;; Limited is for signed user only
655-
;; Private is only for member of the organization
656-
;; Public is for everyone
654+
;; Limited is for users visible only to signed users
655+
;; Private is for users visible only to members of their organizations
656+
;; Public is for users visible for everyone
657+
;DEFAULT_USER_VISIBILITY = public
658+
;;
659+
;; Set whitch visibibilty modes a user can have
660+
;ALLOWED_USER_VISIBILITY_MODES = public,limited,private
661+
;;
662+
;; Either "public", "limited" or "private", default is "public"
663+
;; Limited is for organizations visible only to signed users
664+
;; Private is for organizations visible only to members of the organization
665+
;; Public is for organizations visible to everyone
657666
;DEFAULT_ORG_VISIBILITY = public
658667
;;
659668
;; Default value for DefaultOrgMemberVisible

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

+2
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ 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.

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

+2
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`

Diff for: integrations/api_user_search_test.go

+31
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+
}

Diff for: integrations/git_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
143143
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
144144
t.Run("LFS", func(t *testing.T) {
145145
defer PrintCurrentTest(t)()
146-
setting.CheckLFSVersion()
146+
git.CheckLFSVersion()
147147
if !setting.LFS.StartServer {
148148
t.Skip()
149149
return
@@ -213,7 +213,7 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
213213
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
214214
assert.Equal(t, littleSize, resp.Length)
215215

216-
setting.CheckLFSVersion()
216+
git.CheckLFSVersion()
217217
if setting.LFS.StartServer {
218218
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS))
219219
resp := session.MakeRequest(t, req, http.StatusOK)
@@ -255,7 +255,7 @@ func mediaTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS
255255
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
256256
assert.Equal(t, littleSize, resp.Length)
257257

258-
setting.CheckLFSVersion()
258+
git.CheckLFSVersion()
259259
if setting.LFS.StartServer {
260260
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS))
261261
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)

Diff for: integrations/integration_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"code.gitea.io/gitea/models"
2828
"code.gitea.io/gitea/modules/base"
29+
"code.gitea.io/gitea/modules/git"
2930
"code.gitea.io/gitea/modules/graceful"
3031
"code.gitea.io/gitea/modules/log"
3132
"code.gitea.io/gitea/modules/queue"
@@ -162,7 +163,7 @@ func initIntegrationTest() {
162163
setting.SetCustomPathAndConf("", "", "")
163164
setting.NewContext()
164165
util.RemoveAll(models.LocalCopyPath())
165-
setting.CheckLFSVersion()
166+
git.CheckLFSVersion()
166167
setting.InitDBConfig()
167168
if err := storage.Init(); err != nil {
168169
fmt.Printf("Init storage failed: %v", err)

Diff for: integrations/lfs_getobject_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"testing"
1414

1515
"code.gitea.io/gitea/models"
16+
"code.gitea.io/gitea/modules/git"
1617
"code.gitea.io/gitea/modules/lfs"
1718
"code.gitea.io/gitea/modules/setting"
1819
"code.gitea.io/gitea/routers/web"
@@ -81,7 +82,7 @@ func checkResponseTestContentEncoding(t *testing.T, content *[]byte, resp *httpt
8182

8283
func TestGetLFSSmall(t *testing.T) {
8384
defer prepareTestEnv(t)()
84-
setting.CheckLFSVersion()
85+
git.CheckLFSVersion()
8586
if !setting.LFS.StartServer {
8687
t.Skip()
8788
return
@@ -94,7 +95,7 @@ func TestGetLFSSmall(t *testing.T) {
9495

9596
func TestGetLFSLarge(t *testing.T) {
9697
defer prepareTestEnv(t)()
97-
setting.CheckLFSVersion()
98+
git.CheckLFSVersion()
9899
if !setting.LFS.StartServer {
99100
t.Skip()
100101
return
@@ -110,7 +111,7 @@ func TestGetLFSLarge(t *testing.T) {
110111

111112
func TestGetLFSGzip(t *testing.T) {
112113
defer prepareTestEnv(t)()
113-
setting.CheckLFSVersion()
114+
git.CheckLFSVersion()
114115
if !setting.LFS.StartServer {
115116
t.Skip()
116117
return
@@ -131,7 +132,7 @@ func TestGetLFSGzip(t *testing.T) {
131132

132133
func TestGetLFSZip(t *testing.T) {
133134
defer prepareTestEnv(t)()
134-
setting.CheckLFSVersion()
135+
git.CheckLFSVersion()
135136
if !setting.LFS.StartServer {
136137
t.Skip()
137138
return
@@ -154,7 +155,7 @@ func TestGetLFSZip(t *testing.T) {
154155

155156
func TestGetLFSRangeNo(t *testing.T) {
156157
defer prepareTestEnv(t)()
157-
setting.CheckLFSVersion()
158+
git.CheckLFSVersion()
158159
if !setting.LFS.StartServer {
159160
t.Skip()
160161
return
@@ -167,7 +168,7 @@ func TestGetLFSRangeNo(t *testing.T) {
167168

168169
func TestGetLFSRange(t *testing.T) {
169170
defer prepareTestEnv(t)()
170-
setting.CheckLFSVersion()
171+
git.CheckLFSVersion()
171172
if !setting.LFS.StartServer {
172173
t.Skip()
173174
return

Diff for: integrations/migration-test/migration_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"code.gitea.io/gitea/models/migrations"
2424
"code.gitea.io/gitea/modules/base"
2525
"code.gitea.io/gitea/modules/charset"
26+
"code.gitea.io/gitea/modules/git"
2627
"code.gitea.io/gitea/modules/setting"
2728
"code.gitea.io/gitea/modules/util"
2829

@@ -61,7 +62,7 @@ func initMigrationTest(t *testing.T) func() {
6162
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
6263
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
6364

64-
setting.CheckLFSVersion()
65+
git.CheckLFSVersion()
6566
setting.InitDBConfig()
6667
setting.NewLogServices(true)
6768
return deferFn

Diff for: models/fixtures/user.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@
508508
num_repos: 0
509509
is_active: true
510510

511-
512511
-
513512
id: 30
514513
lower_name: user30
@@ -525,3 +524,20 @@
525524
avatar_email: user30@example.com
526525
num_repos: 2
527526
is_active: true
527+
528+
-
529+
id: 31
530+
lower_name: user31
531+
name: user31
532+
full_name: "user31"
533+
email: user31@example.com
534+
passwd_hash_algo: argon2
535+
passwd: a3d5fcd92bae586c2e3dbe72daea7a0d27833a8d0227aa1704f4bbd775c1f3b03535b76dd93b0d4d8d22a519dca47df1547b # password
536+
type: 0 # individual
537+
salt: ZogKvWdyEx
538+
is_admin: false
539+
visibility: 2
540+
avatar: avatar31
541+
avatar_email: user31@example.com
542+
num_repos: 0
543+
is_active: true

Diff for: models/migrations/migrations_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"code.gitea.io/gitea/models"
1818
"code.gitea.io/gitea/modules/base"
19+
"code.gitea.io/gitea/modules/git"
1920
"code.gitea.io/gitea/modules/setting"
2021
"code.gitea.io/gitea/modules/timeutil"
2122
"code.gitea.io/gitea/modules/util"
@@ -55,7 +56,7 @@ func TestMain(m *testing.M) {
5556

5657
setting.SetCustomPathAndConf("", "", "")
5758
setting.NewContext()
58-
setting.CheckLFSVersion()
59+
git.CheckLFSVersion()
5960
setting.InitDBConfig()
6061
setting.NewLogServices(true)
6162

0 commit comments

Comments
 (0)