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)}}">

0 commit comments

Comments
 (0)