Allow syncing with mirror option checked

This commit is contained in:
harryzcy 2022-07-15 23:33:55 -04:00
parent aa7f59e5fc
commit 5b1c73ecac
No known key found for this signature in database
GPG Key ID: CC2953E050C19686
4 changed files with 11 additions and 8 deletions

View File

@ -29,6 +29,7 @@ type Downloader interface {
FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
// For syncing issues and pull requests
SupportSyncing() bool
GetNewIssues(page, perPage int, updatedAfter time.Time) ([]*Issue, bool, error)
GetNewComments(commentable Commentable, updatedAfter time.Time) ([]*Comment, bool, error)
GetAllNewComments(page, perPage int, updatedAfter time.Time) ([]*Comment, bool, error)

View File

@ -89,6 +89,11 @@ func (n NullDownloader) SupportGetRepoComments() bool {
return false
}
// SupportSyncing returns true if it supports syncing issues/PRs/etc from pull mirror
func (n NullDownloader) SupportSyncing() bool {
return false
}
// GetNewIssues returns new issues updated after the given time according start and limit
func (n NullDownloader) GetNewIssues(page, perPage int, updatedAfter time.Time) ([]*Issue, bool, error) {
return nil, false, ErrNotSupported{Entity: "NewIssues"}

View File

@ -223,14 +223,6 @@ func MigratePost(ctx *context.Context) {
PullRequests: form.PullRequests,
Releases: form.Releases,
}
if opts.Mirror {
opts.Issues = false
opts.Milestones = false
opts.Labels = false
opts.Comments = false
opts.PullRequests = false
opts.Releases = false
}
err = repo_model.CheckCreateRepository(ctx.Doer, ctxUser, opts.RepoName, false)
if err != nil {

View File

@ -470,6 +470,11 @@ func SyncRepository(ctx context.Context, doer *user_model.User, ownerName string
return nil, err
}
if !downloader.SupportSyncing() {
log.Info("repository syncing is not supported, ignored")
return nil, nil
}
uploader := NewGiteaLocalUploader(ctx, doer, ownerName, opts.RepoName)
uploader.gitServiceType = opts.GitServiceType