summaryrefslogtreecommitdiffstats
path: root/modules/cron
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-14 14:10:42 +0800
committerLauris BH <lauris@nix.lv>2019-10-14 09:10:42 +0300
commite3e44a59d01da3af2be3a830f4a90394e7af4ff4 (patch)
treef66e8ead94693225668bacd0ba603bf3712aeae6 /modules/cron
parentba201aaa44b19f633fab0c4682d5f97558b3205e (diff)
downloadgitea-e3e44a59d01da3af2be3a830f4a90394e7af4ff4.tar.gz
gitea-e3e44a59d01da3af2be3a830f4a90394e7af4ff4.zip
Update migrated repositories' issues/comments/prs poster id if user has a github external user saved (#7751)
* update migrated issues/comments when login as github * add get userid when migrating or login with github oauth2 * fix lint * add migrations for repository service type * fix build * remove unnecessary dependencies on migrations * add cron task to update migrations poster ids and fix posterid when migrating * fix lint * fix lint * improve code * fix lint * improve code * replace releases publish id to actual author id * fix import * fix bug * fix lint * fix rawdata definition * fix some bugs * fix error message
Diffstat (limited to 'modules/cron')
-rw-r--r--modules/cron/cron.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/modules/cron/cron.go b/modules/cron/cron.go
index 089f0fa767..795fafb51f 100644
--- a/modules/cron/cron.go
+++ b/modules/cron/cron.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/migrations"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/sync"
mirror_service "code.gitea.io/gitea/services/mirror"
@@ -18,12 +19,13 @@ import (
)
const (
- mirrorUpdate = "mirror_update"
- gitFsck = "git_fsck"
- checkRepos = "check_repos"
- archiveCleanup = "archive_cleanup"
- syncExternalUsers = "sync_external_users"
- deletedBranchesCleanup = "deleted_branches_cleanup"
+ mirrorUpdate = "mirror_update"
+ gitFsck = "git_fsck"
+ checkRepos = "check_repos"
+ archiveCleanup = "archive_cleanup"
+ syncExternalUsers = "sync_external_users"
+ deletedBranchesCleanup = "deleted_branches_cleanup"
+ updateMigrationPosterID = "update_migration_post_id"
)
var c = cron.New()
@@ -117,6 +119,15 @@ func NewContext() {
go WithUnique(deletedBranchesCleanup, models.RemoveOldDeletedBranches)()
}
}
+
+ entry, err = c.AddFunc("Update migrated repositories' issues and comments' posterid", setting.Cron.UpdateMigrationPosterID.Schedule, WithUnique(updateMigrationPosterID, migrations.UpdateMigrationPosterID))
+ if err != nil {
+ log.Fatal("Cron[Update migrated repositories]: %v", err)
+ }
+ entry.Prev = time.Now()
+ entry.ExecTimes++
+ go WithUnique(updateMigrationPosterID, migrations.UpdateMigrationPosterID)()
+
c.Start()
}