Skip to content

Commit 66b4a39

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Clarify the logger's MODE config option (go-gitea#26267) speed up TestEventSourceManagerRun (go-gitea#26262) Merge `templates/projects/list.tmpl` and `templates/repo/projects/list.tmpl` together (go-gitea#26265) Allow editing push mirrors after creation (go-gitea#26151) Update Arch linux URL from community to extra (go-gitea#26273) Fix due date rendering the wrong date in issue (go-gitea#26268) Some fixes of the prompt of new branches (go-gitea#26257)
2 parents 60900e0 + 54c28fd commit 66b4a39

File tree

16 files changed

+121
-114
lines changed

16 files changed

+121
-114
lines changed

docs/content/administration/logging-config.en-us.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ MODE = file, file-error
102102

103103
; by default, the "file" mode will record logs to %(log.ROOT_PATH)/gitea.log, so we don't need to set it
104104
; [log.file]
105+
; by default, the MODE (actually it's the output writer of this logger) is taken from the section name, so we don't need to set it either
106+
; MODE = file
105107

106108
[log.file-error]
109+
MODE = file
107110
LEVEL = Error
108111
FILE_NAME = file-error.log
109112
```

docs/content/installation/from-package.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ apk add gitea
4040

4141
## Arch Linux
4242

43-
The rolling release distribution has [Gitea](https://www.archlinux.org/packages/community/x86_64/gitea/) in their official community repository and package updates are provided with new Gitea releases.
43+
The rolling release distribution has [Gitea](https://www.archlinux.org/packages/extra/x86_64/gitea/) in their official extra repository and package updates are provided with new Gitea releases.
4444

4545
```sh
4646
pacman -S gitea

models/git/branch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64, ex
395395
Where("pusher_id=? AND is_deleted=?", userID, false).
396396
And("name <> ?", excludeBranchName).
397397
And("repo_id = ?", repoID).
398-
And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()).
398+
And("commit_time >= ?", time.Now().Add(-time.Hour*6).Unix()).
399399
NotIn("name", subQuery).
400-
OrderBy("branch.updated_unix DESC").
400+
OrderBy("branch.commit_time DESC").
401401
Limit(2).
402402
Find(&branches)
403403
return branches, err

models/repo/pushmirror.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ func UpdatePushMirror(ctx context.Context, m *PushMirror) error {
8585
return err
8686
}
8787

88+
// UpdatePushMirrorInterval updates the push-mirror
89+
func UpdatePushMirrorInterval(ctx context.Context, m *PushMirror) error {
90+
_, err := db.GetEngine(ctx).ID(m.ID).Cols("interval").Update(m)
91+
return err
92+
}
93+
8894
func DeletePushMirrors(ctx context.Context, opts PushMirrorOptions) error {
8995
if opts.RepoID > 0 {
9096
_, err := db.GetEngine(ctx).Where(opts.toConds()).Delete(&PushMirror{})

modules/setting/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func loadLogModeByName(rootCfg ConfigProvider, loggerName, modeName string) (wri
165165
writerMode.WriterOption = writerOption
166166
default:
167167
if !log.HasEventWriter(writerType) {
168-
return "", "", writerMode, fmt.Errorf("invalid log writer type (mode): %s", writerType)
168+
return "", "", writerMode, fmt.Errorf("invalid log writer type (mode): %s, maybe it needs something like 'MODE=file' in [log.%s] section", writerType, modeName)
169169
}
170170
}
171171

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,8 @@ settings.mirror_settings.last_update = Last update
19661966
settings.mirror_settings.push_mirror.none = No push mirrors configured
19671967
settings.mirror_settings.push_mirror.remote_url = Git Remote Repository URL
19681968
settings.mirror_settings.push_mirror.add = Add Push Mirror
1969+
settings.mirror_settings.push_mirror.edit_sync_time = Edit mirror sync interval
1970+
19691971
settings.sync_mirror = Synchronize Now
19701972
settings.mirror_sync_in_progress = Mirror synchronization is in progress. Check back in a minute.
19711973
settings.site = Website

routers/web/repo/setting/setting.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,43 @@ func SettingsPost(ctx *context.Context) {
299299
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
300300
ctx.Redirect(repo.Link() + "/settings")
301301

302+
case "push-mirror-update":
303+
if !setting.Mirror.Enabled {
304+
ctx.NotFound("", nil)
305+
return
306+
}
307+
308+
// This section doesn't require repo_name/RepoName to be set in the form, don't show it
309+
// as an error on the UI for this action
310+
ctx.Data["Err_RepoName"] = nil
311+
312+
interval, err := time.ParseDuration(form.PushMirrorInterval)
313+
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
314+
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &forms.RepoSettingForm{})
315+
return
316+
}
317+
318+
id, err := strconv.ParseInt(form.PushMirrorID, 10, 64)
319+
if err != nil {
320+
ctx.ServerError("UpdatePushMirrorIntervalPushMirrorID", err)
321+
return
322+
}
323+
m := &repo_model.PushMirror{
324+
ID: id,
325+
Interval: interval,
326+
}
327+
if err := repo_model.UpdatePushMirrorInterval(ctx, m); err != nil {
328+
ctx.ServerError("UpdatePushMirrorInterval", err)
329+
return
330+
}
331+
// Background why we are adding it to Queue
332+
// If we observed its implementation in the context of `push-mirror-sync` where it
333+
// is evident that pushing to the queue is necessary for updates.
334+
// So, there are updates within the given interval, it is necessary to update the queue accordingly.
335+
mirror_module.AddPushMirrorToQueue(m.ID)
336+
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
337+
ctx.Redirect(repo.Link() + "/settings")
338+
302339
case "push-mirror-remove":
303340
if !setting.Mirror.Enabled {
304341
ctx.NotFound("", nil)

routers/web/repo/view.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,18 @@ func renderCode(ctx *context.Context) {
999999
ctx.ServerError("GetBaseRepo", err)
10001000
return
10011001
}
1002-
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
1003-
if err != nil {
1004-
ctx.ServerError("GetRecentlyPushedBranches", err)
1005-
return
1002+
1003+
showRecentlyPushedNewBranches := true
1004+
if ctx.Repo.Repository.IsMirror ||
1005+
!ctx.Repo.Repository.UnitEnabled(ctx, unit_model.TypePullRequests) {
1006+
showRecentlyPushedNewBranches = false
1007+
}
1008+
if showRecentlyPushedNewBranches {
1009+
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
1010+
if err != nil {
1011+
ctx.ServerError("GetRecentlyPushedBranches", err)
1012+
return
1013+
}
10061014
}
10071015
}
10081016

templates/projects/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{if .CanWriteProjects}}
1+
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
22
<div class="gt-text-right">
33
<a class="ui small green button" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
44
</div>
@@ -72,7 +72,7 @@
7272
{{template "base/paginate" .}}
7373
</div>
7474

75-
{{if $.CanWriteProjects}}
75+
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
7676
<div class="ui g-modal-confirm delete modal">
7777
<div class="header">
7878
{{svg "octicon-trash"}}

templates/repo/code/recently_pushed_new_branches.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{range .RecentlyPushedNewBranches}}
22
<div class="ui positive message gt-df gt-ac">
33
<div class="gt-f1">
4-
{{$timeSince := TimeSince .UpdatedUnix.AsTime $.locale}}
4+
{{$timeSince := TimeSince .CommitTime.AsTime $.locale}}
55
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
66
</div>
77
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
<div class="gt-df gt-sb gt-ac">
375375
<div class="due-date {{if .Issue.IsOverdue}}text red{{end}}" {{if .Issue.IsOverdue}}data-tooltip-content="{{.locale.Tr "repo.issues.due_date_overdue"}}"{{end}}>
376376
{{svg "octicon-calendar" 16 "gt-mr-3"}}
377-
{{DateTime "long" .Issue.DeadlineUnix}}
377+
{{DateTime "long" .Issue.DeadlineUnix.FormatDate}}
378378
</div>
379379
<div>
380380
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}

templates/repo/projects/list.tmpl

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,7 @@
22
<div role="main" aria-label="{{.Title}}" class="page-content repository projects milestones">
33
{{template "repo/header" .}}
44
<div class="ui container">
5-
<div class="navbar projects-header">
6-
<div>
7-
<div class="small-menu-items ui compact tiny menu">
8-
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=open">
9-
{{svg "octicon-project" 16 "gt-mr-3"}}
10-
{{.locale.PrettyNumber .OpenCount}}&nbsp;{{.locale.Tr "repo.issues.open_title"}}
11-
</a>
12-
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=closed">
13-
{{svg "octicon-check" 16 "gt-mr-3"}}
14-
{{.locale.PrettyNumber .ClosedCount}}&nbsp;{{.locale.Tr "repo.issues.closed_title"}}
15-
</a>
16-
</div>
17-
</div>
18-
<div class="projects-toolbar">
19-
<!-- Sort -->
20-
<div class="ui small dropdown type jump item">
21-
<span class="text">
22-
{{.locale.Tr "repo.issues.filter_sort"}}
23-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
24-
</span>
25-
<div class="menu">
26-
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&sort=oldest&state={{$.State}}">{{.locale.Tr "repo.issues.filter_sort.oldest"}}</a>
27-
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&sort=recentupdate&state={{$.State}}">{{.locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
28-
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&sort=leastupdate&state={{$.State}}">{{.locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
29-
</div>
30-
</div>
31-
{{if and .CanWriteProjects (not .Repository.IsArchived)}}
32-
<a class="ui small green button gt-ml-4" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
33-
{{end}}
34-
</div>
35-
</div>
36-
{{template "base/alert" .}}
37-
38-
<div class="milestone-list">
39-
{{range .Projects}}
40-
<li class="milestone-card">
41-
<h3 class="flex-text-block gt-m-0">
42-
{{svg .IconName 16}}
43-
<a class="muted" href="{{.Link}}">{{.Title}}</a>
44-
</h3>
45-
<div class="milestone-toolbar">
46-
<div class="group">
47-
<div class="flex-text-block">
48-
{{svg "octicon-issue-opened" 14}}
49-
{{$.locale.PrettyNumber .NumOpenIssues}}&nbsp;{{$.locale.Tr "repo.issues.open_title"}}
50-
</div>
51-
<div class="flex-text-block">
52-
{{svg "octicon-check" 14}}
53-
{{$.locale.PrettyNumber .NumClosedIssues}}&nbsp;{{$.locale.Tr "repo.issues.closed_title"}}
54-
</div>
55-
</div>
56-
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
57-
<div class="group">
58-
<a class="flex-text-inline" href="{{.Link}}/edit">{{svg "octicon-pencil" 14}}{{$.locale.Tr "repo.issues.label_edit"}}</a>
59-
{{if .IsClosed}}
60-
<a class="link-action flex-text-inline" href data-url="{{.Link}}/open">{{svg "octicon-check" 14}}{{$.locale.Tr "repo.projects.open"}}</a>
61-
{{else}}
62-
<a class="link-action flex-text-inline" href data-url="{{.Link}}/close">{{svg "octicon-skip" 14}}{{$.locale.Tr "repo.projects.close"}}</a>
63-
{{end}}
64-
<a class="delete-button flex-text-inline" href="#" data-url="{{.Link}}/delete">{{svg "octicon-trash" 14}}{{$.locale.Tr "repo.issues.label_delete"}}</a>
65-
</div>
66-
{{end}}
67-
</div>
68-
{{if .Description}}
69-
<div class="content">
70-
{{.RenderedContent|Str2html}}
71-
</div>
72-
{{end}}
73-
</li>
74-
{{end}}
75-
76-
{{template "base/paginate" .}}
77-
</div>
5+
{{template "projects/list" .}}
786
</div>
797
</div>
80-
81-
{{if .CanWriteProjects}}
82-
<div class="ui g-modal-confirm delete modal">
83-
<div class="header">
84-
{{svg "octicon-trash"}}
85-
{{.locale.Tr "repo.projects.deletion"}}
86-
</div>
87-
<div class="content">
88-
<p>{{.locale.Tr "repo.projects.deletion_desc"}}</p>
89-
</div>
90-
{{template "base/modal_actions_confirm" .}}
91-
</div>
92-
{{end}}
938
{{template "base/footer" .}}

templates/repo/settings/options.tmpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,27 @@
203203
<td>{{$.locale.Tr "repo.settings.mirror_settings.direction.push"}}</td>
204204
<td>{{if .LastUpdateUnix}}{{DateTime "full" .LastUpdateUnix}}{{else}}{{$.locale.Tr "never"}}{{end}} {{if .LastError}}<div class="ui red label" data-tooltip-content="{{.LastError}}">{{$.locale.Tr "error"}}</div>{{end}}</td>
205205
<td class="right aligned">
206+
<button
207+
class="ui tiny button show-modal"
208+
data-modal="#push-mirror-edit-modal"
209+
data-tooltip-content="{{$.locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}}"
210+
data-modal-push-mirror-edit-id="{{.ID}}"
211+
data-modal-push-mirror-edit-interval="{{.Interval}}"
212+
data-modal-push-mirror-edit-address="{{$address.Address}}"
213+
>
214+
{{svg "octicon-pencil" 14}}
215+
</button>
206216
<form method="post" class="gt-dib">
207217
{{$.CsrfTokenHtml}}
208-
<input type="hidden" name="action" value="push-mirror-remove">
218+
<input type="hidden" name="action" value="push-mirror-sync">
209219
<input type="hidden" name="push_mirror_id" value="{{.ID}}">
210-
<button class="ui basic red tiny button inline text-thin">{{$.locale.Tr "remove"}}</button>
220+
<button class="ui primary tiny button" data-tooltip-content="{{$.locale.Tr "repo.settings.sync_mirror"}}">{{svg "octicon-sync" 14}}</button>
211221
</form>
212222
<form method="post" class="gt-dib">
213223
{{$.CsrfTokenHtml}}
214-
<input type="hidden" name="action" value="push-mirror-sync">
224+
<input type="hidden" name="action" value="push-mirror-remove">
215225
<input type="hidden" name="push_mirror_id" value="{{.ID}}">
216-
<button class="ui primary tiny button inline text-thin">{{$.locale.Tr "repo.settings.sync_mirror"}}</button>
226+
<button class="ui basic red tiny button" data-tooltip-content="{{$.locale.Tr "remove"}}">{{svg "octicon-trash" 14}}</button>
217227
</form>
218228
</td>
219229
</tr>
@@ -980,3 +990,5 @@
980990
</div>
981991
{{end}}
982992
{{end}}
993+
994+
{{template "repo/settings/push_mirror_sync_modal" .}}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="ui small modal" id="push-mirror-edit-modal">
2+
<div class="header">
3+
{{$.locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}}
4+
</div>
5+
<div class="content">
6+
<form class="ui form ignore-dirty" method="post">
7+
{{.CsrfTokenHtml}}
8+
<input type="hidden" name="action" value="push-mirror-update">
9+
<input type="hidden" name="push_mirror_id" id="push-mirror-edit-id">
10+
<div class="field">
11+
<label for="name">{{$.locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</label>
12+
<div class="ui small input">
13+
<input id="push-mirror-edit-address" readonly>
14+
</div>
15+
</div>
16+
<div class="inline field">
17+
<label for="push-mirror-edit-interval">{{.locale.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
18+
<input id="push-mirror-edit-interval" name="push_mirror_interval" autofocus>
19+
</div>
20+
<div class="actions">
21+
<button class="ui small basic cancel button">
22+
{{svg "octicon-x"}}
23+
{{.locale.Tr "cancel"}}
24+
</button>
25+
<button class="ui primary small approve button">
26+
{{svg "fontawesome-save"}}
27+
{{.locale.Tr "save"}}
28+
</button>
29+
</div>
30+
</form>
31+
</div>
32+
</div>

tests/test_utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"path"
1313
"path/filepath"
1414
"testing"
15+
"time"
1516

1617
"code.gitea.io/gitea/models/db"
1718
packages_model "code.gitea.io/gitea/models/packages"
@@ -43,6 +44,9 @@ func InitTest(requireGitea bool) {
4344
exitf("Environment variable $GITEA_ROOT not set")
4445
}
4546

47+
// Speedup tests that rely on the event source ticker.
48+
setting.UI.Notification.EventSourceUpdateTime = time.Second
49+
4650
setting.IsInTesting = true
4751
setting.AppWorkPath = giteaRoot
4852
setting.CustomPath = filepath.Join(setting.AppWorkPath, "custom")

web_src/css/repo.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@
8787
}
8888
}
8989

90-
.projects-header {
91-
margin-bottom: 1rem;
92-
flex-direction: column;
93-
gap: 8px;
94-
}
95-
96-
.projects-toolbar {
97-
display: flex;
98-
justify-content: space-between;
99-
padding-left: 4px;
100-
}
101-
10290
.repository .issue-content-right .menu {
10391
overflow-x: auto;
10492
max-height: 500px;

0 commit comments

Comments
 (0)