mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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
This commit is contained in:
		@@ -153,6 +153,43 @@ type EditRepoOption struct {
 | 
			
		||||
	Archived *bool `json:"archived,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GitServiceType represents a git service
 | 
			
		||||
type GitServiceType int
 | 
			
		||||
 | 
			
		||||
// enumerate all GitServiceType
 | 
			
		||||
const (
 | 
			
		||||
	NotMigrated     GitServiceType = iota // 0 not migrated from external sites
 | 
			
		||||
	PlainGitService                       // 1 plain git service
 | 
			
		||||
	GithubService                         // 2 github.com
 | 
			
		||||
	GiteaService                          // 3 gitea service
 | 
			
		||||
	GitlabService                         // 4 gitlab service
 | 
			
		||||
	GogsService                           // 5 gogs service
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Name represents the service type's name
 | 
			
		||||
// WARNNING: the name have to be equal to that on goth's library
 | 
			
		||||
func (gt GitServiceType) Name() string {
 | 
			
		||||
	switch gt {
 | 
			
		||||
	case GithubService:
 | 
			
		||||
		return "github"
 | 
			
		||||
	case GiteaService:
 | 
			
		||||
		return "gitea"
 | 
			
		||||
	case GitlabService:
 | 
			
		||||
		return "gitlab"
 | 
			
		||||
	case GogsService:
 | 
			
		||||
		return "gogs"
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// SupportedFullGitService represents all git services supported to migrate issues/labels/prs and etc.
 | 
			
		||||
	// TODO: add to this list after new git service added
 | 
			
		||||
	SupportedFullGitService = []GitServiceType{
 | 
			
		||||
		GithubService,
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// MigrateRepoOption options for migrating a repository from an external service
 | 
			
		||||
type MigrateRepoOption struct {
 | 
			
		||||
	// required: true
 | 
			
		||||
@@ -166,6 +203,8 @@ type MigrateRepoOption struct {
 | 
			
		||||
	Mirror          bool   `json:"mirror"`
 | 
			
		||||
	Private         bool   `json:"private"`
 | 
			
		||||
	Description     string `json:"description"`
 | 
			
		||||
	OriginalURL     string
 | 
			
		||||
	GitServiceType  GitServiceType
 | 
			
		||||
	Wiki            bool
 | 
			
		||||
	Issues          bool
 | 
			
		||||
	Milestones      bool
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user