Skip to content

Commit a8dc6ec

Browse files
authored
Merge branch 'main' into create-user-system-defaults
2 parents 5ceff35 + 72479bf commit a8dc6ec

File tree

150 files changed

+2423
-1090
lines changed

Some content is hidden

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

150 files changed

+2423
-1090
lines changed

cmd/serv.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ func runServ(c *cli.Context) error {
296296
gitcmd = exec.CommandContext(ctx, verb, repoPath)
297297
}
298298

299+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
300+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
301+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
302+
if os.IsNotExist(err) {
303+
return fail("Incorrect configuration.",
304+
"Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.")
305+
}
306+
}
307+
299308
gitcmd.Dir = setting.RepoRootPath
300309
gitcmd.Stdout = os.Stdout
301310
gitcmd.Stdin = os.Stdin

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RUN_MODE = ; prod
237237
;; PPROF_DATA_PATH, use an absolute path when you start gitea as service
238238
;PPROF_DATA_PATH = data/tmp/pprof
239239
;;
240-
;; Landing page, can be "home", "explore", "organizations" or "login"
240+
;; Landing page, can be "home", "explore", "organizations", "login", or any URL such as "/org/repo" or even "https://anotherwebsite.com"
241241
;; The "login" choice is not a security measure but just a UI flow change, use REQUIRE_SIGNIN_VIEW to force users to log in.
242242
;LANDING_PAGE = home
243243
;;
@@ -879,7 +879,7 @@ PATH =
879879
;DISABLE_STARS = false
880880
;;
881881
;; The default branch name of new repositories
882-
;DEFAULT_BRANCH = master
882+
;DEFAULT_BRANCH = main
883883
;;
884884
;; Allow adoption of unadopted repositories
885885
;ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES = false

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
7575
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
7676
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
7777
- `DISABLE_STARS`: **false**: Disable stars feature.
78-
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
78+
- `DEFAULT_BRANCH`: **main**: Default branch name of all repositories.
7979
- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to adopt unadopted repositories
8080
- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to delete unadopted repositories
8181

@@ -300,8 +300,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
300300
- `ENABLE_GZIP`: **false**: Enable gzip compression for runtime-generated content, static resources excluded.
301301
- `ENABLE_PPROF`: **false**: Application profiling (memory and cpu). For "web" command it listens on localhost:6060. For "serv" command it dumps to disk at `PPROF_DATA_PATH` as `(cpuprofile|memprofile)_<username>_<temporary id>`
302302
- `PPROF_DATA_PATH`: **data/tmp/pprof**: `PPROF_DATA_PATH`, use an absolute path when you start Gitea as service
303-
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login\].
304-
303+
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login, **custom**\]. Where custom would instead be any URL such as "/org/repo" or even `https://anotherwebsite.com`
305304
- `LFS_START_SERVER`: **false**: Enables Git LFS support.
306305
- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)/lfs**: Default LFS content path. (if it is on local storage.) **DEPRECATED** use settings in `[lfs]`.
307306
- `LFS_JWT_SECRET`: **\<empty\>**: LFS authentication secret, change this a unique string.

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ MODE = console
287287
LEVEL = debug ; please set the level to debug when we are debugging a problem
288288
ROUTER = console
289289
COLORIZE = false ; this can be true if you can strip out the ansi coloring
290+
ENABLE_SSH_LOG = true ; shows logs related to git over SSH.
290291
```
291292

292293
Sometimes it will be helpful get some specific `TRACE` level logging restricted
@@ -445,7 +446,7 @@ Gitea includes built-in log rotation, which should be enough for most deployment
445446
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
446447
- Install `logrotate`.
447448
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
448-
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
449+
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
449450
- If you are using docker and are running from outside of the container you can use `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the Gitea process itself.
450451

451452
The next `logrotate` jobs will include your configurations, so no restart is needed. You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.

integrations/api_issue_milestone_test.go

Lines changed: 2 additions & 2 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+
issues_model "code.gitea.io/gitea/models/issues"
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"
@@ -21,7 +21,7 @@ import (
2121
func TestAPIIssuesMilestone(t *testing.T) {
2222
defer prepareTestEnv(t)()
2323

24-
milestone := unittest.AssertExistsAndLoadBean(t, &models.Milestone{ID: 1}).(*models.Milestone)
24+
milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}).(*issues_model.Milestone)
2525
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: milestone.RepoID}).(*repo_model.Repository)
2626
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
2727
assert.Equal(t, int64(1), int64(milestone.NumIssues))

integrations/api_issue_reaction_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"code.gitea.io/gitea/models"
14+
"code.gitea.io/gitea/models/db"
1415
"code.gitea.io/gitea/models/unittest"
1516
user_model "code.gitea.io/gitea/models/user"
1617
"code.gitea.io/gitea/modules/convert"
@@ -23,7 +24,7 @@ func TestAPIIssuesReactions(t *testing.T) {
2324
defer prepareTestEnv(t)()
2425

2526
issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1}).(*models.Issue)
26-
_ = issue.LoadRepo()
27+
_ = issue.LoadRepo(db.DefaultContext)
2728
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}).(*user_model.User)
2829

2930
session := loginUser(t, owner.Name)
@@ -82,7 +83,7 @@ func TestAPICommentReactions(t *testing.T) {
8283
comment := unittest.AssertExistsAndLoadBean(t, &models.Comment{ID: 2}).(*models.Comment)
8384
_ = comment.LoadIssue()
8485
issue := comment.Issue
85-
_ = issue.LoadRepo()
86+
_ = issue.LoadRepo(db.DefaultContext)
8687
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}).(*user_model.User)
8788

8889
session := loginUser(t, owner.Name)

integrations/api_issue_stopwatch_test.go

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

1111
"code.gitea.io/gitea/models"
12+
"code.gitea.io/gitea/models/db"
1213
repo_model "code.gitea.io/gitea/models/repo"
1314
"code.gitea.io/gitea/models/unittest"
1415
user_model "code.gitea.io/gitea/models/user"
@@ -45,7 +46,7 @@ func TestAPIStopStopWatches(t *testing.T) {
4546
defer prepareTestEnv(t)()
4647

4748
issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
48-
_ = issue.LoadRepo()
49+
_ = issue.LoadRepo(db.DefaultContext)
4950
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}).(*user_model.User)
5051
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
5152

@@ -61,7 +62,7 @@ func TestAPICancelStopWatches(t *testing.T) {
6162
defer prepareTestEnv(t)()
6263

6364
issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1}).(*models.Issue)
64-
_ = issue.LoadRepo()
65+
_ = issue.LoadRepo(db.DefaultContext)
6566
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}).(*user_model.User)
6667
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).(*user_model.User)
6768

@@ -77,7 +78,7 @@ func TestAPIStartStopWatches(t *testing.T) {
7778
defer prepareTestEnv(t)()
7879

7980
issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 3}).(*models.Issue)
80-
_ = issue.LoadRepo()
81+
_ = issue.LoadRepo(db.DefaultContext)
8182
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}).(*user_model.User)
8283
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
8384

integrations/api_issue_test.go

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -168,30 +168,30 @@ func TestAPIEditIssue(t *testing.T) {
168168
func TestAPISearchIssues(t *testing.T) {
169169
defer prepareTestEnv(t)()
170170

171-
session := loginUser(t, "user2")
172-
token := getTokenForLoggedInUser(t, session)
171+
token := getUserToken(t, "user2")
173172

174173
link, _ := url.Parse("/api/v1/repos/issues/search")
175-
req := NewRequest(t, "GET", link.String())
176-
resp := session.MakeRequest(t, req, http.StatusOK)
174+
req := NewRequest(t, "GET", link.String()+"?token="+token)
175+
resp := MakeRequest(t, req, http.StatusOK)
177176
var apiIssues []*api.Issue
178177
DecodeJSON(t, resp, &apiIssues)
179178
assert.Len(t, apiIssues, 10)
180179

181180
query := url.Values{"token": {token}}
182181
link.RawQuery = query.Encode()
183182
req = NewRequest(t, "GET", link.String())
184-
resp = session.MakeRequest(t, req, http.StatusOK)
183+
resp = MakeRequest(t, req, http.StatusOK)
185184
DecodeJSON(t, resp, &apiIssues)
186185
assert.Len(t, apiIssues, 10)
187186

188187
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
189188
before := time.Unix(999307200, 0).Format(time.RFC3339)
190189
query.Add("since", since)
191190
query.Add("before", before)
191+
query.Add("token", token)
192192
link.RawQuery = query.Encode()
193193
req = NewRequest(t, "GET", link.String())
194-
resp = session.MakeRequest(t, req, http.StatusOK)
194+
resp = MakeRequest(t, req, http.StatusOK)
195195
DecodeJSON(t, resp, &apiIssues)
196196
assert.Len(t, apiIssues, 8)
197197
query.Del("since")
@@ -200,77 +200,76 @@ func TestAPISearchIssues(t *testing.T) {
200200
query.Add("state", "closed")
201201
link.RawQuery = query.Encode()
202202
req = NewRequest(t, "GET", link.String())
203-
resp = session.MakeRequest(t, req, http.StatusOK)
203+
resp = MakeRequest(t, req, http.StatusOK)
204204
DecodeJSON(t, resp, &apiIssues)
205205
assert.Len(t, apiIssues, 2)
206206

207207
query.Set("state", "all")
208208
link.RawQuery = query.Encode()
209209
req = NewRequest(t, "GET", link.String())
210-
resp = session.MakeRequest(t, req, http.StatusOK)
210+
resp = MakeRequest(t, req, http.StatusOK)
211211
DecodeJSON(t, resp, &apiIssues)
212212
assert.EqualValues(t, "15", resp.Header().Get("X-Total-Count"))
213213
assert.Len(t, apiIssues, 10) // there are more but 10 is page item limit
214214

215215
query.Add("limit", "20")
216216
link.RawQuery = query.Encode()
217217
req = NewRequest(t, "GET", link.String())
218-
resp = session.MakeRequest(t, req, http.StatusOK)
218+
resp = MakeRequest(t, req, http.StatusOK)
219219
DecodeJSON(t, resp, &apiIssues)
220220
assert.Len(t, apiIssues, 15)
221221

222-
query = url.Values{"assigned": {"true"}, "state": {"all"}}
222+
query = url.Values{"assigned": {"true"}, "state": {"all"}, "token": {token}}
223223
link.RawQuery = query.Encode()
224224
req = NewRequest(t, "GET", link.String())
225-
resp = session.MakeRequest(t, req, http.StatusOK)
225+
resp = MakeRequest(t, req, http.StatusOK)
226226
DecodeJSON(t, resp, &apiIssues)
227227
assert.Len(t, apiIssues, 1)
228228

229-
query = url.Values{"milestones": {"milestone1"}, "state": {"all"}}
229+
query = url.Values{"milestones": {"milestone1"}, "state": {"all"}, "token": {token}}
230230
link.RawQuery = query.Encode()
231231
req = NewRequest(t, "GET", link.String())
232-
resp = session.MakeRequest(t, req, http.StatusOK)
232+
resp = MakeRequest(t, req, http.StatusOK)
233233
DecodeJSON(t, resp, &apiIssues)
234234
assert.Len(t, apiIssues, 1)
235235

236-
query = url.Values{"milestones": {"milestone1,milestone3"}, "state": {"all"}}
236+
query = url.Values{"milestones": {"milestone1,milestone3"}, "state": {"all"}, "token": {token}}
237237
link.RawQuery = query.Encode()
238238
req = NewRequest(t, "GET", link.String())
239-
resp = session.MakeRequest(t, req, http.StatusOK)
239+
resp = MakeRequest(t, req, http.StatusOK)
240240
DecodeJSON(t, resp, &apiIssues)
241241
assert.Len(t, apiIssues, 2)
242242

243-
query = url.Values{"owner": {"user2"}} // user
243+
query = url.Values{"owner": {"user2"}, "token": {token}} // user
244244
link.RawQuery = query.Encode()
245245
req = NewRequest(t, "GET", link.String())
246-
resp = session.MakeRequest(t, req, http.StatusOK)
246+
resp = MakeRequest(t, req, http.StatusOK)
247247
DecodeJSON(t, resp, &apiIssues)
248248
assert.Len(t, apiIssues, 6)
249249

250-
query = url.Values{"owner": {"user3"}} // organization
250+
query = url.Values{"owner": {"user3"}, "token": {token}} // organization
251251
link.RawQuery = query.Encode()
252252
req = NewRequest(t, "GET", link.String())
253-
resp = session.MakeRequest(t, req, http.StatusOK)
253+
resp = MakeRequest(t, req, http.StatusOK)
254254
DecodeJSON(t, resp, &apiIssues)
255255
assert.Len(t, apiIssues, 3)
256256

257-
query = url.Values{"owner": {"user3"}, "team": {"team1"}} // organization + team
257+
query = url.Values{"owner": {"user3"}, "team": {"team1"}, "token": {token}} // organization + team
258258
link.RawQuery = query.Encode()
259259
req = NewRequest(t, "GET", link.String())
260-
resp = session.MakeRequest(t, req, http.StatusOK)
260+
resp = MakeRequest(t, req, http.StatusOK)
261261
DecodeJSON(t, resp, &apiIssues)
262262
assert.Len(t, apiIssues, 2)
263263
}
264264

265265
func TestAPISearchIssuesWithLabels(t *testing.T) {
266266
defer prepareTestEnv(t)()
267267

268-
session := loginUser(t, "user1")
269-
token := getTokenForLoggedInUser(t, session)
268+
token := getUserToken(t, "user1")
270269

271270
link, _ := url.Parse("/api/v1/repos/issues/search")
272-
req := NewRequest(t, "GET", link.String())
273-
resp := session.MakeRequest(t, req, http.StatusOK)
271+
req := NewRequest(t, "GET", link.String()+"?token="+token)
272+
resp := MakeRequest(t, req, http.StatusOK)
274273
var apiIssues []*api.Issue
275274
DecodeJSON(t, resp, &apiIssues)
276275

@@ -280,30 +279,30 @@ func TestAPISearchIssuesWithLabels(t *testing.T) {
280279
query.Add("token", token)
281280
link.RawQuery = query.Encode()
282281
req = NewRequest(t, "GET", link.String())
283-
resp = session.MakeRequest(t, req, http.StatusOK)
282+
resp = MakeRequest(t, req, http.StatusOK)
284283
DecodeJSON(t, resp, &apiIssues)
285284
assert.Len(t, apiIssues, 10)
286285

287286
query.Add("labels", "label1")
288287
link.RawQuery = query.Encode()
289288
req = NewRequest(t, "GET", link.String())
290-
resp = session.MakeRequest(t, req, http.StatusOK)
289+
resp = MakeRequest(t, req, http.StatusOK)
291290
DecodeJSON(t, resp, &apiIssues)
292291
assert.Len(t, apiIssues, 2)
293292

294293
// multiple labels
295294
query.Set("labels", "label1,label2")
296295
link.RawQuery = query.Encode()
297296
req = NewRequest(t, "GET", link.String())
298-
resp = session.MakeRequest(t, req, http.StatusOK)
297+
resp = MakeRequest(t, req, http.StatusOK)
299298
DecodeJSON(t, resp, &apiIssues)
300299
assert.Len(t, apiIssues, 2)
301300

302301
// an org label
303302
query.Set("labels", "orglabel4")
304303
link.RawQuery = query.Encode()
305304
req = NewRequest(t, "GET", link.String())
306-
resp = session.MakeRequest(t, req, http.StatusOK)
305+
resp = MakeRequest(t, req, http.StatusOK)
307306
DecodeJSON(t, resp, &apiIssues)
308307
assert.Len(t, apiIssues, 1)
309308

@@ -312,15 +311,15 @@ func TestAPISearchIssuesWithLabels(t *testing.T) {
312311
query.Add("state", "all")
313312
link.RawQuery = query.Encode()
314313
req = NewRequest(t, "GET", link.String())
315-
resp = session.MakeRequest(t, req, http.StatusOK)
314+
resp = MakeRequest(t, req, http.StatusOK)
316315
DecodeJSON(t, resp, &apiIssues)
317316
assert.Len(t, apiIssues, 2)
318317

319318
// org and repo label which share the same issue
320319
query.Set("labels", "label1,orglabel4")
321320
link.RawQuery = query.Encode()
322321
req = NewRequest(t, "GET", link.String())
323-
resp = session.MakeRequest(t, req, http.StatusOK)
322+
resp = MakeRequest(t, req, http.StatusOK)
324323
DecodeJSON(t, resp, &apiIssues)
325324
assert.Len(t, apiIssues, 2)
326325
}

integrations/api_issue_tracked_time_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"code.gitea.io/gitea/models"
14+
"code.gitea.io/gitea/models/db"
1415
"code.gitea.io/gitea/models/unittest"
1516
user_model "code.gitea.io/gitea/models/user"
1617
api "code.gitea.io/gitea/modules/structs"
@@ -23,7 +24,7 @@ func TestAPIGetTrackedTimes(t *testing.T) {
2324

2425
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
2526
issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
26-
assert.NoError(t, issue2.LoadRepo())
27+
assert.NoError(t, issue2.LoadRepo(db.DefaultContext))
2728

2829
session := loginUser(t, user2.Name)
2930
token := getTokenForLoggedInUser(t, session)
@@ -65,7 +66,7 @@ func TestAPIDeleteTrackedTime(t *testing.T) {
6566

6667
time6 := unittest.AssertExistsAndLoadBean(t, &models.TrackedTime{ID: 6}).(*models.TrackedTime)
6768
issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
68-
assert.NoError(t, issue2.LoadRepo())
69+
assert.NoError(t, issue2.LoadRepo(db.DefaultContext))
6970
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
7071

7172
session := loginUser(t, user2.Name)
@@ -99,7 +100,7 @@ func TestAPIAddTrackedTimes(t *testing.T) {
99100
defer prepareTestEnv(t)()
100101

101102
issue2 := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
102-
assert.NoError(t, issue2.LoadRepo())
103+
assert.NoError(t, issue2.LoadRepo(db.DefaultContext))
103104
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
104105
admin := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).(*user_model.User)
105106

0 commit comments

Comments
 (0)