Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Aug 2, 2023
2 parents 60900e0 + 54c28fd commit 66b4a39
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 114 deletions.
3 changes: 3 additions & 0 deletions docs/content/administration/logging-config.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ MODE = file, file-error

; by default, the "file" mode will record logs to %(log.ROOT_PATH)/gitea.log, so we don't need to set it
; [log.file]
; 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
; MODE = file

[log.file-error]
MODE = file
LEVEL = Error
FILE_NAME = file-error.log
```
Expand Down
2 changes: 1 addition & 1 deletion docs/content/installation/from-package.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ apk add gitea

## Arch Linux

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.
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.

```sh
pacman -S gitea
Expand Down
4 changes: 2 additions & 2 deletions models/git/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64, ex
Where("pusher_id=? AND is_deleted=?", userID, false).
And("name <> ?", excludeBranchName).
And("repo_id = ?", repoID).
And("updated_unix >= ?", time.Now().Add(-time.Hour*6).Unix()).
And("commit_time >= ?", time.Now().Add(-time.Hour*6).Unix()).
NotIn("name", subQuery).
OrderBy("branch.updated_unix DESC").
OrderBy("branch.commit_time DESC").
Limit(2).
Find(&branches)
return branches, err
Expand Down
6 changes: 6 additions & 0 deletions models/repo/pushmirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func UpdatePushMirror(ctx context.Context, m *PushMirror) error {
return err
}

// UpdatePushMirrorInterval updates the push-mirror
func UpdatePushMirrorInterval(ctx context.Context, m *PushMirror) error {
_, err := db.GetEngine(ctx).ID(m.ID).Cols("interval").Update(m)
return err
}

func DeletePushMirrors(ctx context.Context, opts PushMirrorOptions) error {
if opts.RepoID > 0 {
_, err := db.GetEngine(ctx).Where(opts.toConds()).Delete(&PushMirror{})
Expand Down
2 changes: 1 addition & 1 deletion modules/setting/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func loadLogModeByName(rootCfg ConfigProvider, loggerName, modeName string) (wri
writerMode.WriterOption = writerOption
default:
if !log.HasEventWriter(writerType) {
return "", "", writerMode, fmt.Errorf("invalid log writer type (mode): %s", writerType)
return "", "", writerMode, fmt.Errorf("invalid log writer type (mode): %s, maybe it needs something like 'MODE=file' in [log.%s] section", writerType, modeName)
}
}

Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,8 @@ settings.mirror_settings.last_update = Last update
settings.mirror_settings.push_mirror.none = No push mirrors configured
settings.mirror_settings.push_mirror.remote_url = Git Remote Repository URL
settings.mirror_settings.push_mirror.add = Add Push Mirror
settings.mirror_settings.push_mirror.edit_sync_time = Edit mirror sync interval

settings.sync_mirror = Synchronize Now
settings.mirror_sync_in_progress = Mirror synchronization is in progress. Check back in a minute.
settings.site = Website
Expand Down
37 changes: 37 additions & 0 deletions routers/web/repo/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,43 @@ func SettingsPost(ctx *context.Context) {
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
ctx.Redirect(repo.Link() + "/settings")

case "push-mirror-update":
if !setting.Mirror.Enabled {
ctx.NotFound("", nil)
return
}

// This section doesn't require repo_name/RepoName to be set in the form, don't show it
// as an error on the UI for this action
ctx.Data["Err_RepoName"] = nil

interval, err := time.ParseDuration(form.PushMirrorInterval)
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &forms.RepoSettingForm{})
return
}

id, err := strconv.ParseInt(form.PushMirrorID, 10, 64)
if err != nil {
ctx.ServerError("UpdatePushMirrorIntervalPushMirrorID", err)
return
}
m := &repo_model.PushMirror{
ID: id,
Interval: interval,
}
if err := repo_model.UpdatePushMirrorInterval(ctx, m); err != nil {
ctx.ServerError("UpdatePushMirrorInterval", err)
return
}
// Background why we are adding it to Queue
// If we observed its implementation in the context of `push-mirror-sync` where it
// is evident that pushing to the queue is necessary for updates.
// So, there are updates within the given interval, it is necessary to update the queue accordingly.
mirror_module.AddPushMirrorToQueue(m.ID)
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
ctx.Redirect(repo.Link() + "/settings")

case "push-mirror-remove":
if !setting.Mirror.Enabled {
ctx.NotFound("", nil)
Expand Down
16 changes: 12 additions & 4 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,10 +999,18 @@ func renderCode(ctx *context.Context) {
ctx.ServerError("GetBaseRepo", err)
return
}
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
if err != nil {
ctx.ServerError("GetRecentlyPushedBranches", err)
return

showRecentlyPushedNewBranches := true
if ctx.Repo.Repository.IsMirror ||
!ctx.Repo.Repository.UnitEnabled(ctx, unit_model.TypePullRequests) {
showRecentlyPushedNewBranches = false
}
if showRecentlyPushedNewBranches {
ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
if err != nil {
ctx.ServerError("GetRecentlyPushedBranches", err)
return
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions templates/projects/list.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{if .CanWriteProjects}}
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
<div class="gt-text-right">
<a class="ui small green button" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
</div>
Expand Down Expand Up @@ -72,7 +72,7 @@
{{template "base/paginate" .}}
</div>

{{if $.CanWriteProjects}}
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
<div class="ui g-modal-confirm delete modal">
<div class="header">
{{svg "octicon-trash"}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/code/recently_pushed_new_branches.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{range .RecentlyPushedNewBranches}}
<div class="ui positive message gt-df gt-ac">
<div class="gt-f1">
{{$timeSince := TimeSince .UpdatedUnix.AsTime $.locale}}
{{$timeSince := TimeSince .CommitTime.AsTime $.locale}}
{{$.locale.Tr "repo.pulls.recently_pushed_new_branches" (PathEscapeSegments .Name) $timeSince | Safe}}
</div>
<a aria-role="button" class="ui compact positive button gt-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo (PathEscapeSegments .Name)}}">
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
<div class="gt-df gt-sb gt-ac">
<div class="due-date {{if .Issue.IsOverdue}}text red{{end}}" {{if .Issue.IsOverdue}}data-tooltip-content="{{.locale.Tr "repo.issues.due_date_overdue"}}"{{end}}>
{{svg "octicon-calendar" 16 "gt-mr-3"}}
{{DateTime "long" .Issue.DeadlineUnix}}
{{DateTime "long" .Issue.DeadlineUnix.FormatDate}}
</div>
<div>
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
Expand Down
87 changes: 1 addition & 86 deletions templates/repo/projects/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,7 @@
<div role="main" aria-label="{{.Title}}" class="page-content repository projects milestones">
{{template "repo/header" .}}
<div class="ui container">
<div class="navbar projects-header">
<div>
<div class="small-menu-items ui compact tiny menu">
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=open">
{{svg "octicon-project" 16 "gt-mr-3"}}
{{.locale.PrettyNumber .OpenCount}}&nbsp;{{.locale.Tr "repo.issues.open_title"}}
</a>
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=closed">
{{svg "octicon-check" 16 "gt-mr-3"}}
{{.locale.PrettyNumber .ClosedCount}}&nbsp;{{.locale.Tr "repo.issues.closed_title"}}
</a>
</div>
</div>
<div class="projects-toolbar">
<!-- Sort -->
<div class="ui small dropdown type jump item">
<span class="text">
{{.locale.Tr "repo.issues.filter_sort"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</span>
<div class="menu">
<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>
<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>
<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>
</div>
</div>
{{if and .CanWriteProjects (not .Repository.IsArchived)}}
<a class="ui small green button gt-ml-4" href="{{$.Link}}/new">{{.locale.Tr "repo.projects.new"}}</a>
{{end}}
</div>
</div>
{{template "base/alert" .}}

<div class="milestone-list">
{{range .Projects}}
<li class="milestone-card">
<h3 class="flex-text-block gt-m-0">
{{svg .IconName 16}}
<a class="muted" href="{{.Link}}">{{.Title}}</a>
</h3>
<div class="milestone-toolbar">
<div class="group">
<div class="flex-text-block">
{{svg "octicon-issue-opened" 14}}
{{$.locale.PrettyNumber .NumOpenIssues}}&nbsp;{{$.locale.Tr "repo.issues.open_title"}}
</div>
<div class="flex-text-block">
{{svg "octicon-check" 14}}
{{$.locale.PrettyNumber .NumClosedIssues}}&nbsp;{{$.locale.Tr "repo.issues.closed_title"}}
</div>
</div>
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
<div class="group">
<a class="flex-text-inline" href="{{.Link}}/edit">{{svg "octicon-pencil" 14}}{{$.locale.Tr "repo.issues.label_edit"}}</a>
{{if .IsClosed}}
<a class="link-action flex-text-inline" href data-url="{{.Link}}/open">{{svg "octicon-check" 14}}{{$.locale.Tr "repo.projects.open"}}</a>
{{else}}
<a class="link-action flex-text-inline" href data-url="{{.Link}}/close">{{svg "octicon-skip" 14}}{{$.locale.Tr "repo.projects.close"}}</a>
{{end}}
<a class="delete-button flex-text-inline" href="#" data-url="{{.Link}}/delete">{{svg "octicon-trash" 14}}{{$.locale.Tr "repo.issues.label_delete"}}</a>
</div>
{{end}}
</div>
{{if .Description}}
<div class="content">
{{.RenderedContent|Str2html}}
</div>
{{end}}
</li>
{{end}}

{{template "base/paginate" .}}
</div>
{{template "projects/list" .}}
</div>
</div>

{{if .CanWriteProjects}}
<div class="ui g-modal-confirm delete modal">
<div class="header">
{{svg "octicon-trash"}}
{{.locale.Tr "repo.projects.deletion"}}
</div>
<div class="content">
<p>{{.locale.Tr "repo.projects.deletion_desc"}}</p>
</div>
{{template "base/modal_actions_confirm" .}}
</div>
{{end}}
{{template "base/footer" .}}
20 changes: 16 additions & 4 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,27 @@
<td>{{$.locale.Tr "repo.settings.mirror_settings.direction.push"}}</td>
<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>
<td class="right aligned">
<button
class="ui tiny button show-modal"
data-modal="#push-mirror-edit-modal"
data-tooltip-content="{{$.locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}}"
data-modal-push-mirror-edit-id="{{.ID}}"
data-modal-push-mirror-edit-interval="{{.Interval}}"
data-modal-push-mirror-edit-address="{{$address.Address}}"
>
{{svg "octicon-pencil" 14}}
</button>
<form method="post" class="gt-dib">
{{$.CsrfTokenHtml}}
<input type="hidden" name="action" value="push-mirror-remove">
<input type="hidden" name="action" value="push-mirror-sync">
<input type="hidden" name="push_mirror_id" value="{{.ID}}">
<button class="ui basic red tiny button inline text-thin">{{$.locale.Tr "remove"}}</button>
<button class="ui primary tiny button" data-tooltip-content="{{$.locale.Tr "repo.settings.sync_mirror"}}">{{svg "octicon-sync" 14}}</button>
</form>
<form method="post" class="gt-dib">
{{$.CsrfTokenHtml}}
<input type="hidden" name="action" value="push-mirror-sync">
<input type="hidden" name="action" value="push-mirror-remove">
<input type="hidden" name="push_mirror_id" value="{{.ID}}">
<button class="ui primary tiny button inline text-thin">{{$.locale.Tr "repo.settings.sync_mirror"}}</button>
<button class="ui basic red tiny button" data-tooltip-content="{{$.locale.Tr "remove"}}">{{svg "octicon-trash" 14}}</button>
</form>
</td>
</tr>
Expand Down Expand Up @@ -980,3 +990,5 @@
</div>
{{end}}
{{end}}

{{template "repo/settings/push_mirror_sync_modal" .}}
32 changes: 32 additions & 0 deletions templates/repo/settings/push_mirror_sync_modal.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="ui small modal" id="push-mirror-edit-modal">
<div class="header">
{{$.locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}}
</div>
<div class="content">
<form class="ui form ignore-dirty" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="push-mirror-update">
<input type="hidden" name="push_mirror_id" id="push-mirror-edit-id">
<div class="field">
<label for="name">{{$.locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</label>
<div class="ui small input">
<input id="push-mirror-edit-address" readonly>
</div>
</div>
<div class="inline field">
<label for="push-mirror-edit-interval">{{.locale.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
<input id="push-mirror-edit-interval" name="push_mirror_interval" autofocus>
</div>
<div class="actions">
<button class="ui small basic cancel button">
{{svg "octicon-x"}}
{{.locale.Tr "cancel"}}
</button>
<button class="ui primary small approve button">
{{svg "fontawesome-save"}}
{{.locale.Tr "save"}}
</button>
</div>
</form>
</div>
</div>
4 changes: 4 additions & 0 deletions tests/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path"
"path/filepath"
"testing"
"time"

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

// Speedup tests that rely on the event source ticker.
setting.UI.Notification.EventSourceUpdateTime = time.Second

setting.IsInTesting = true
setting.AppWorkPath = giteaRoot
setting.CustomPath = filepath.Join(setting.AppWorkPath, "custom")
Expand Down
12 changes: 0 additions & 12 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@
}
}

.projects-header {
margin-bottom: 1rem;
flex-direction: column;
gap: 8px;
}

.projects-toolbar {
display: flex;
justify-content: space-between;
padding-left: 4px;
}

.repository .issue-content-right .menu {
overflow-x: auto;
max-height: 500px;
Expand Down

0 comments on commit 66b4a39

Please sign in to comment.