Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Improve names of cron jobs for Actions (go-gitea#31736)
  [skip ci] Updated translations via Crowdin
  Fix the display of project type for deleted projects (go-gitea#31732)
  Fix Null Pointer error for CommitStatusesHideActionsURL (go-gitea#31731)
  Move `registerActionsCleanup` to `initActionsTasks` (go-gitea#31721)
  • Loading branch information
zjjhot committed Jul 31, 2024
2 parents 7057df3 + 9ac57c9 commit f387831
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 32 deletions.
4 changes: 4 additions & 0 deletions models/git/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ func ConvertFromGitCommit(ctx context.Context, commits []*git.Commit, repo *repo
func CommitStatusesHideActionsURL(ctx context.Context, statuses []*CommitStatus) {
idToRepos := make(map[int64]*repo_model.Repository)
for _, status := range statuses {
if status == nil {
continue
}

if status.Repo == nil {
status.Repo = idToRepos[status.RepoID]
}
Expand Down
7 changes: 7 additions & 0 deletions models/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ type Project struct {
ClosedDateUnix timeutil.TimeStamp
}

// Ghost Project is a project which has been deleted
const GhostProjectID = -1

func (p *Project) IsGhost() bool {
return p.ID == GhostProjectID
}

func (p *Project) LoadOwner(ctx context.Context) (err error) {
if p.Owner != nil {
return nil
Expand Down
15 changes: 8 additions & 7 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ dashboard.reinit_missing_repos = Reinitialize all missing Git repositories for w
dashboard.sync_external_users = Synchronize external user data
dashboard.cleanup_hook_task_table = Cleanup hook_task table
dashboard.cleanup_packages = Cleanup expired packages
dashboard.cleanup_actions = Cleanup actions expired logs and artifacts
dashboard.cleanup_actions = Cleanup expired actions resources
dashboard.server_uptime = Server Uptime
dashboard.current_goroutine = Current Goroutines
dashboard.current_memory_usage = Current Memory Usage
Expand Down Expand Up @@ -2900,15 +2900,15 @@ dashboard.total_gc_time = Total GC Pause
dashboard.total_gc_pause = Total GC Pause
dashboard.last_gc_pause = Last GC Pause
dashboard.gc_times = GC Times
dashboard.delete_old_actions = Delete all old actions from database
dashboard.delete_old_actions.started = Delete all old actions from database started.
dashboard.delete_old_actions = Delete all old activities from database
dashboard.delete_old_actions.started = Delete all old activities from database started.
dashboard.update_checker = Update checker
dashboard.delete_old_system_notices = Delete all old system notices from database
dashboard.gc_lfs = Garbage collect LFS meta objects
dashboard.stop_zombie_tasks = Stop zombie tasks
dashboard.stop_endless_tasks = Stop endless tasks
dashboard.cancel_abandoned_jobs = Cancel abandoned jobs
dashboard.start_schedule_tasks = Start schedule tasks
dashboard.stop_zombie_tasks = Stop actions zombie tasks
dashboard.stop_endless_tasks = Stop actions endless tasks
dashboard.cancel_abandoned_jobs = Cancel actions abandoned jobs
dashboard.start_schedule_tasks = Start actions schedule tasks
dashboard.sync_branch.started = Branches Sync started
dashboard.sync_tag.started = Tags Sync started
dashboard.rebuild_issue_indexer = Rebuild issue indexer
Expand Down Expand Up @@ -3705,6 +3705,7 @@ variables.update.failed = Failed to edit variable.
variables.update.success = The variable has been edited.
[projects]
deleted.display_name = Deleted Project
type-1.display_name = Individual Project
type-2.display_name = Repository Project
type-3.display_name = Organization Project
Expand Down
5 changes: 5 additions & 0 deletions options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ compare.compare_head=comparer
pulls.desc=Active les demandes d’ajouts et l’évaluation du code.
pulls.new=Nouvelle demande d'ajout
pulls.new.blocked_user=Impossible de créer une demande d’ajout car vous êtes bloqué par le propriétaire du dépôt.
pulls.new.must_collaborator=Vous devez être un collaborateur pour créer une demande d’ajout.
pulls.edit.already_changed=Impossible d’enregistrer la demande d’ajout. Il semble que le contenu ait été modifié par un autre utilisateur. Veuillez rafraîchir la page et réessayer afin d’éviter d’écraser leurs modifications.
pulls.view=Voir la demande d'ajout
pulls.compare_changes=Nouvelle demande d’ajout
Expand Down Expand Up @@ -2981,6 +2982,10 @@ emails.not_updated=Impossible de mettre à jour l’adresse courriel demandée :
emails.duplicate_active=Cette adresse courriel est déjà active pour un autre utilisateur.
emails.change_email_header=Mettre à jour les propriétés du courriel
emails.change_email_text=Êtes-vous sûr de vouloir mettre à jour cette adresse courriel ?
emails.delete=Supprimer l’e-mail
emails.delete_desc=Êtes-vous sûr de vouloir supprimer cette adresse e-mail ?
emails.deletion_success=L’adresse e-mail a été supprimée.
emails.delete_primary_email_error=Vous ne pouvez pas supprimer l’e-mail principal.

orgs.org_manage_panel=Gestion des organisations
orgs.name=Nom
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ compare.compare_head=comparar
pulls.desc=Habilitar pedidos de integração e revisão de código.
pulls.new=Novo pedido de integração
pulls.new.blocked_user=Não pode criar o pedido de integração porque foi bloqueado/a pelo/a proprietário/a do repositório.
pulls.new.must_collaborator=Tem de ser um/a colaborador/a para criar um pedido de integração.
pulls.edit.already_changed=Não foi possível guardar as modificações do pedido de integração. O conteúdo parece ter sido modificado por outro utilizador, entretanto. Refresque a página e tente editar de novo para evitar sobrepor as modificações dele.
pulls.view=Ver pedido de integração
pulls.compare_changes=Novo pedido de integração
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ func ViewIssue(ctx *context.Context) {
}

ghostProject := &project_model.Project{
ID: -1,
ID: project_model.GhostProjectID,
Title: ctx.Locale.TrString("repo.issues.deleted_project"),
}

Expand Down
3 changes: 1 addition & 2 deletions services/actions/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ package actions

import (
"context"
"time"

"code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/storage"
)

// Cleanup removes expired actions logs, data and artifacts
func Cleanup(taskCtx context.Context, olderThan time.Duration) error {
func Cleanup(taskCtx context.Context) error {
// TODO: clean up expired actions logs

// clean up expired artifacts
Expand Down
11 changes: 11 additions & 0 deletions services/cron/tasks_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func initActionsTasks() {
registerStopEndlessTasks()
registerCancelAbandonedJobs()
registerScheduleTasks()
registerActionsCleanup()
}

func registerStopZombieTasks() {
Expand Down Expand Up @@ -63,3 +64,13 @@ func registerScheduleTasks() {
return actions_service.StartScheduleTasks(ctx)
})
}

func registerActionsCleanup() {
RegisterTaskFatal("cleanup_actions", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@midnight",
}, func(ctx context.Context, _ *user_model.User, _ Config) error {
return actions_service.Cleanup(ctx)
})
}
18 changes: 0 additions & 18 deletions services/cron/tasks_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/actions"
"code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/migrations"
mirror_service "code.gitea.io/gitea/services/mirror"
Expand Down Expand Up @@ -157,20 +156,6 @@ func registerCleanupPackages() {
})
}

func registerActionsCleanup() {
RegisterTaskFatal("cleanup_actions", &OlderThanConfig{
BaseConfig: BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@midnight",
},
OlderThan: 24 * time.Hour,
}, func(ctx context.Context, _ *user_model.User, config Config) error {
realConfig := config.(*OlderThanConfig)
return actions.Cleanup(ctx, realConfig.OlderThan)
})
}

func initBasicTasks() {
if setting.Mirror.Enabled {
registerUpdateMirrorTask()
Expand All @@ -187,7 +172,4 @@ func initBasicTasks() {
if setting.Packages.Enabled {
registerCleanupPackages()
}
if setting.Actions.Enabled {
registerActionsCleanup()
}
}
14 changes: 10 additions & 4 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,19 @@
{{template "shared/user/authorlink" .Poster}}
{{$oldProjectDisplayHtml := "Unknown Project"}}
{{if .OldProject}}
{{$trKey := printf "projects.type-%d.display_name" .OldProject.Type}}
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .OldProject.Title}}
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
{{if not .OldProject.IsGhost}}
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type)}}
{{end}}
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .OldProject.Title}}
{{end}}
{{$newProjectDisplayHtml := "Unknown Project"}}
{{if .Project}}
{{$trKey := printf "projects.type-%d.display_name" .Project.Type}}
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .Project.Title}}
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
{{if not .Project.IsGhost}}
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .Project.Type)}}
{{end}}
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .Project.Title}}
{{end}}
{{if and (gt .OldProjectID 0) (gt .ProjectID 0)}}
{{ctx.Locale.Tr "repo.issues.change_project_at" $oldProjectDisplayHtml $newProjectDisplayHtml $createdStr}}
Expand Down

0 comments on commit f387831

Please sign in to comment.