Skip to content

Commit 590a12b

Browse files
authored
Merge branch 'main' into notif3
2 parents fed2afa + 81ce271 commit 590a12b

File tree

15 files changed

+77
-17
lines changed

15 files changed

+77
-17
lines changed

cmd/manager.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
Subcommands: []cli.Command{
2222
subcmdShutdown,
2323
subcmdRestart,
24+
subcmdReloadTemplates,
2425
subcmdFlushQueues,
2526
subcmdLogging,
2627
subCmdProcesses,
@@ -46,6 +47,16 @@ var (
4647
},
4748
Action: runRestart,
4849
}
50+
subcmdReloadTemplates = cli.Command{
51+
Name: "reload-templates",
52+
Usage: "Reload template files in the running process",
53+
Flags: []cli.Flag{
54+
cli.BoolFlag{
55+
Name: "debug",
56+
},
57+
},
58+
Action: runReloadTemplates,
59+
}
4960
subcmdFlushQueues = cli.Command{
5061
Name: "flush-queues",
5162
Usage: "Flush queues in the running process",
@@ -115,6 +126,15 @@ func runRestart(c *cli.Context) error {
115126
return handleCliResponseExtra(extra)
116127
}
117128

129+
func runReloadTemplates(c *cli.Context) error {
130+
ctx, cancel := installSignals()
131+
defer cancel()
132+
133+
setup(ctx, c.Bool("debug"))
134+
extra := private.ReloadTemplates(ctx)
135+
return handleCliResponseExtra(extra)
136+
}
137+
118138
func runFlushQueues(c *cli.Context) error {
119139
ctx, cancel := installSignals()
120140
defer cancel()

docs/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.19.0
22-
minGoVersion: 1.19
21+
version: 1.19.0 # FIXME: this version was used as "latest stable release", but it always gets outdated and doesn't make sense
22+
minGoVersion: 1.20
2323
goVersion: 1.20
2424
minNodeVersion: 16
2525
search: nav

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ A "login prohibited" user is a user that is not allowed to log in to Gitea anymo
136136

137137
## Setting up logging
138138

139-
- [Official Docs]({{< relref "doc/administration/logging-documentation.en-us.md" >}})
139+
- [Official Docs]({{< relref "doc/administration/logging-config.en-us.md" >}})
140140

141141
## What is Swagger?
142142

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
code.gitea.io/actions-proto-go v0.2.1

models/issues/issue_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func getIssueStatsChunk(opts *IssuesOptions, issueIDs []int64) (*IssueStats, err
141141
if opts.AssigneeID > 0 {
142142
applyAssigneeCondition(sess, opts.AssigneeID)
143143
} else if opts.AssigneeID == db.NoConditionID {
144-
sess.Where("id NOT IN (SELECT issue_id FROM issue_assignees)")
144+
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
145145
}
146146

147147
if opts.PosterID > 0 {

modules/private/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ func Restart(ctx context.Context) ResponseExtra {
2929
return requestJSONClientMsg(req, "Restarting")
3030
}
3131

32+
// ReloadTemplates calls the internal reload-templates function
33+
func ReloadTemplates(ctx context.Context) ResponseExtra {
34+
reqURL := setting.LocalURL + "api/internal/manager/reload-templates"
35+
req := newInternalRequest(ctx, reqURL, "POST")
36+
return requestJSONClientMsg(req, "Reloaded")
37+
}
38+
3239
// FlushOptions represents the options for the flush call
3340
type FlushOptions struct {
3441
Timeout time.Duration

modules/templates/htmlrenderer.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ func HTMLRenderer() *HTMLRender {
9696
return htmlRender
9797
}
9898

99+
func ReloadHTMLTemplates() error {
100+
if err := htmlRender.CompileTemplates(); err != nil {
101+
log.Error("Template error: %v\n%s", err, log.Stack(2))
102+
return err
103+
}
104+
return nil
105+
}
106+
99107
func initHTMLRenderer() {
100108
rendererType := "static"
101109
if !setting.IsProd {
@@ -115,9 +123,7 @@ func initHTMLRenderer() {
115123

116124
if !setting.IsProd {
117125
go AssetFS().WatchLocalChanges(graceful.GetManager().ShutdownContext(), func() {
118-
if err := htmlRender.CompileTemplates(); err != nil {
119-
log.Error("Template error: %v\n%s", err, log.Stack(2))
120-
}
126+
_ = ReloadHTMLTemplates()
121127
})
122128
}
123129
}

routers/api/v1/repo/fork.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package repo
66

77
import (
8+
"errors"
89
"fmt"
910
"net/http"
1011

@@ -15,6 +16,7 @@ import (
1516
user_model "code.gitea.io/gitea/models/user"
1617
"code.gitea.io/gitea/modules/context"
1718
api "code.gitea.io/gitea/modules/structs"
19+
"code.gitea.io/gitea/modules/util"
1820
"code.gitea.io/gitea/modules/web"
1921
"code.gitea.io/gitea/routers/api/v1/utils"
2022
"code.gitea.io/gitea/services/convert"
@@ -141,7 +143,7 @@ func CreateFork(ctx *context.APIContext) {
141143
Description: repo.Description,
142144
})
143145
if err != nil {
144-
if repo_service.IsErrForkAlreadyExist(err) || repo_model.IsErrRepoAlreadyExist(err) || repo_model.IsErrReachLimitOfRepo(err) {
146+
if errors.Is(err, util.ErrAlreadyExist) || repo_model.IsErrReachLimitOfRepo(err) {
145147
ctx.Error(http.StatusConflict, "ForkRepository", err)
146148
} else {
147149
ctx.Error(http.StatusInternalServerError, "ForkRepository", err)

routers/private/internal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func Routes() *web.Route {
6767
r.Get("/serv/command/{keyid}/{owner}/{repo}", ServCommand)
6868
r.Post("/manager/shutdown", Shutdown)
6969
r.Post("/manager/restart", Restart)
70+
r.Post("/manager/reload-templates", ReloadTemplates)
7071
r.Post("/manager/flush-queues", bind(private.FlushOptions{}), FlushQueues)
7172
r.Post("/manager/pause-logging", PauseLogging)
7273
r.Post("/manager/resume-logging", ResumeLogging)

routers/private/manager.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ import (
1515
"code.gitea.io/gitea/modules/private"
1616
"code.gitea.io/gitea/modules/queue"
1717
"code.gitea.io/gitea/modules/setting"
18+
"code.gitea.io/gitea/modules/templates"
1819
"code.gitea.io/gitea/modules/web"
1920
)
2021

22+
// ReloadTemplates reloads all the templates
23+
func ReloadTemplates(ctx *context.PrivateContext) {
24+
err := templates.ReloadHTMLTemplates()
25+
if err != nil {
26+
ctx.JSON(http.StatusInternalServerError, private.Response{
27+
UserMsg: fmt.Sprintf("Template error: %v", err),
28+
})
29+
return
30+
}
31+
ctx.PlainText(http.StatusOK, "success")
32+
}
33+
2134
// FlushQueues flushes all the Queues
2235
func FlushQueues(ctx *context.PrivateContext) {
2336
opts := web.GetForm(ctx).(*private.FlushOptions)

routers/web/repo/pull.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ func ForkPost(ctx *context.Context) {
272272
ctx.RenderWithErr(msg, tplFork, &form)
273273
case repo_model.IsErrRepoAlreadyExist(err):
274274
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplFork, &form)
275+
case repo_model.IsErrRepoFilesAlreadyExist(err):
276+
switch {
277+
case ctx.IsUserSiteAdmin() || (setting.Repository.AllowAdoptionOfUnadoptedRepositories && setting.Repository.AllowDeleteOfUnadoptedRepositories):
278+
ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.adopt_or_delete"), tplFork, form)
279+
case setting.Repository.AllowAdoptionOfUnadoptedRepositories:
280+
ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.adopt"), tplFork, form)
281+
case setting.Repository.AllowDeleteOfUnadoptedRepositories:
282+
ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist.delete"), tplFork, form)
283+
default:
284+
ctx.RenderWithErr(ctx.Tr("form.repository_files_already_exist"), tplFork, form)
285+
}
275286
case db.IsErrNameReserved(err):
276287
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(db.ErrNameReserved).Name), tplFork, &form)
277288
case db.IsErrNamePatternNotAllowed(err):

templates/repo/home.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@
6464
<div class="repo-button-row gt-df gt-ac gt-sb gt-fw">
6565
<div class="gt-df gt-ac gt-fw gt-gap-y-3">
6666
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "gt-mr-2"}}
67-
{{$n := len .TreeNames}}
68-
{{$l := Eval $n "-" 1}}
69-
<!-- If home page, show new pr. If not, show breadcrumb -->
70-
{{if and (eq $n 0) .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
67+
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
7168
{{$cmpBranch := ""}}
7269
{{if ne .Repository.ID .BaseRepo.ID}}
7370
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
@@ -79,6 +76,9 @@
7976
{{svg "octicon-git-pull-request"}}
8077
</a>
8178
{{end}}
79+
<!-- Show go to file and breadcrumbs if not on home page -->
80+
{{$n := len .TreeNames}}
81+
{{$l := Eval $n "-" 1}}
8282
{{if eq $n 0}}
8383
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{.locale.Tr "repo.find_file.go_to_file"}}</a>
8484
{{end}}

templates/repo/issue/view_content/comments_delete_time.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{.ctxData.CsrfTokenHtml}}
88
</form>
99
<div class="header">{{.ctxData.locale.Tr "repo.issues.del_time"}}</div>
10-
{{template "base/modal_actions_confirm" .}}
10+
{{template "base/modal_actions_confirm" (dict "locale" .ctxData.locale)}}
1111
</div>
1212
<button class="ui icon button compact mini issue-delete-time" data-id="{{.comment.Time.ID}}" data-tooltip-content="{{.ctxData.locale.Tr "repo.issues.del_time"}}">
1313
{{svg "octicon-trash"}}

templates/user/dashboard/milestones.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<div class="ui stackable grid">
66
<div class="four wide column">
77
<div class="ui secondary vertical filter menu gt-bg-transparent">
8-
<a class="item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
8+
<div class="item">
99
{{.locale.Tr "home.issues.in_your_repos"}}
1010
<strong class="ui right">{{.Total}}</strong>
11-
</a>
11+
</div>
1212
<div class="ui divider"></div>
1313
{{range .Repos}}
1414
{{with $Repo := .}}

web_src/css/base.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--fonts-proportional: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial;
44
--fonts-monospace: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, var(--fonts-emoji);
55
--fonts-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla";
6-
/* font weights - use between 400 and 600 for general purposes */
6+
/* font weights - use between 400 and 600 for general purposes. Avoid 700 as it is perceived too bold */
77
--font-weight-light: 300;
88
--font-weight-normal: 400;
99
--font-weight-medium: 500;

0 commit comments

Comments
 (0)