Define interfaces syncing new issues/PRs

This commit is contained in:
Chongyi Zheng 2022-07-10 17:03:49 -04:00
parent 2399b5900a
commit 6f513103c9
No known key found for this signature in database
GPG Key ID: CC2953E050C19686
2 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,7 @@ package migration
import (
"context"
"time"
"code.gitea.io/gitea/modules/structs"
)
@ -26,6 +27,10 @@ type Downloader interface {
GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)
GetReviews(reviewable Reviewable) ([]*Review, error)
FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
// For syncing issues and pull requests
GetNewIssues(page, perPage int, updatedAfter time.Time) ([]*Issue, bool, error)
GetNewPullRequests(page, perPage int, updatedAfter time.Time) ([]*PullRequest, bool, error)
}
// DownloaderFactory defines an interface to match a downloader implementation and create a downloader

View File

@ -7,6 +7,7 @@ package migration
import (
"context"
"net/url"
"time"
)
// NullDownloader implements a blank downloader
@ -87,3 +88,13 @@ func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (
func (n NullDownloader) SupportGetRepoComments() 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: "Issues"}
}
// GetNewPullRequests returns pull requests after the given time according page and perPage
func (n NullDownloader) GetNewPullRequests(page, perPage int, updatedAfter time.Time) ([]*PullRequest, bool, error) {
return nil, false, ErrNotSupported{Entity: "PullRequests"}
}