1
// Copyright 2021 The Gitea Authors. All rights reserved.
2
// SPDX-License-Identifier: MIT
11
// NullDownloader implements a blank downloader
12
type NullDownloader struct{}
14
var _ Downloader = &NullDownloader{}
16
// SetContext set context
17
func (n NullDownloader) SetContext(_ context.Context) {}
19
// GetRepoInfo returns a repository information
20
func (n NullDownloader) GetRepoInfo() (*Repository, error) {
21
return nil, ErrNotSupported{Entity: "RepoInfo"}
24
// GetTopics return repository topics
25
func (n NullDownloader) GetTopics() ([]string, error) {
26
return nil, ErrNotSupported{Entity: "Topics"}
29
// GetMilestones returns milestones
30
func (n NullDownloader) GetMilestones() ([]*Milestone, error) {
31
return nil, ErrNotSupported{Entity: "Milestones"}
34
// GetReleases returns releases
35
func (n NullDownloader) GetReleases() ([]*Release, error) {
36
return nil, ErrNotSupported{Entity: "Releases"}
39
// GetLabels returns labels
40
func (n NullDownloader) GetLabels() ([]*Label, error) {
41
return nil, ErrNotSupported{Entity: "Labels"}
44
// GetIssues returns issues according start and limit
45
func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error) {
46
return nil, false, ErrNotSupported{Entity: "Issues"}
49
// GetComments returns comments of an issue or PR
50
func (n NullDownloader) GetComments(commentable Commentable) ([]*Comment, bool, error) {
51
return nil, false, ErrNotSupported{Entity: "Comments"}
54
// GetAllComments returns paginated comments
55
func (n NullDownloader) GetAllComments(page, perPage int) ([]*Comment, bool, error) {
56
return nil, false, ErrNotSupported{Entity: "AllComments"}
59
// GetPullRequests returns pull requests according page and perPage
60
func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error) {
61
return nil, false, ErrNotSupported{Entity: "PullRequests"}
64
// GetReviews returns pull requests review
65
func (n NullDownloader) GetReviews(reviewable Reviewable) ([]*Review, error) {
66
return nil, ErrNotSupported{Entity: "Reviews"}
69
// FormatCloneURL add authentication into remote URLs
70
func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error) {
71
if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 {
72
u, err := url.Parse(remoteAddr)
76
u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword)
77
if len(opts.AuthToken) > 0 {
78
u.User = url.UserPassword("oauth2", opts.AuthToken)
80
return u.String(), nil
82
return remoteAddr, nil
85
// SupportGetRepoComments return true if it supports get repo comments
86
func (n NullDownloader) SupportGetRepoComments() bool {