* Refactor Cron and merge dashboard tasks
* Merge Cron and Dashboard tasks
* Make every cron task report a system notice on completion
* Refactor the creation of these tasks
* Ensure that execution counts of tasks is correct
* Allow cron tasks to be started from the cron page
* golangci-lint fixes
* Enforce that only one task with the same name can be registered
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix name check
Signed-off-by: Andrew Thornton <art27@cantab.net>
* as per @guillep2k
* as per @lafriks
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add git.CommandContext variants
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
log.Warn("CheckRepoStats: Aborting due to shutdown")
return
log.Warn("CheckRepoStats: Cancelled during %s for repo ID %d",desc,id)
returnErrCancelledf("during %s for repo ID %d",desc,id)
default:
}
id:=com.StrTo(result["id"]).MustInt64()
log.Trace("Updating %s: %d",desc,id)
_,err=x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?",id,true,false,id)
log.Warn("CheckRepoStats: Aborting due to shutdown")
return
log.Warn("CheckRepoStats: Cancelled")
returnErrCancelledf("during %s for repo ID %d",desc,id)
default:
}
id:=com.StrTo(result["id"]).MustInt64()
log.Trace("Updating %s: %d",desc,id)
_,err=x.Exec("UPDATE `repository` SET num_closed_pulls=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?",id,true,true,id)
entry,err=c.AddFunc("Clean up old repository archives",setting.Cron.ArchiveCleanup.Schedule,WithUnique(archiveCleanup,models.DeleteOldRepositoryArchives))
iferr!=nil{
log.Fatal("Cron[Clean up old repository archives]: %v",err)
entry,err=c.AddFunc("Remove old deleted branches",setting.Cron.DeletedBranchesCleanup.Schedule,WithUnique(deletedBranchesCleanup,models.RemoveOldDeletedBranches))
iferr!=nil{
log.Fatal("Cron[Remove old deleted branches]: %v",err)
// Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it
cargs:=make([]string,len(GlobalCommandArgs))
copy(cargs,GlobalCommandArgs)
return&Command{
name:GitExecutable,
args:append(cargs,args...),
parentContext:DefaultContext,
parentContext:ctx,
}
}
// NewCommandNoGlobals creates and returns a new Git Command based on given command and arguments only with the specify args and don't care global command args
// NewCommandContextNoGlobals creates and returns a new Git Command based on given command and arguments only with the specify args and don't care global command args