code.gitea.io/gitea@v1.19.3/modules/migration/null_downloader.go (about) 1 // Copyright 2021 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package migration 5 6 import ( 7 "context" 8 "net/url" 9 ) 10 11 // NullDownloader implements a blank downloader 12 type NullDownloader struct{} 13 14 var _ Downloader = &NullDownloader{} 15 16 // SetContext set context 17 func (n NullDownloader) SetContext(_ context.Context) {} 18 19 // GetRepoInfo returns a repository information 20 func (n NullDownloader) GetRepoInfo() (*Repository, error) { 21 return nil, ErrNotSupported{Entity: "RepoInfo"} 22 } 23 24 // GetTopics return repository topics 25 func (n NullDownloader) GetTopics() ([]string, error) { 26 return nil, ErrNotSupported{Entity: "Topics"} 27 } 28 29 // GetMilestones returns milestones 30 func (n NullDownloader) GetMilestones() ([]*Milestone, error) { 31 return nil, ErrNotSupported{Entity: "Milestones"} 32 } 33 34 // GetReleases returns releases 35 func (n NullDownloader) GetReleases() ([]*Release, error) { 36 return nil, ErrNotSupported{Entity: "Releases"} 37 } 38 39 // GetLabels returns labels 40 func (n NullDownloader) GetLabels() ([]*Label, error) { 41 return nil, ErrNotSupported{Entity: "Labels"} 42 } 43 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"} 47 } 48 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"} 52 } 53 54 // GetAllComments returns paginated comments 55 func (n NullDownloader) GetAllComments(page, perPage int) ([]*Comment, bool, error) { 56 return nil, false, ErrNotSupported{Entity: "AllComments"} 57 } 58 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"} 62 } 63 64 // GetReviews returns pull requests review 65 func (n NullDownloader) GetReviews(reviewable Reviewable) ([]*Review, error) { 66 return nil, ErrNotSupported{Entity: "Reviews"} 67 } 68 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) 73 if err != nil { 74 return "", err 75 } 76 u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword) 77 if len(opts.AuthToken) > 0 { 78 u.User = url.UserPassword("oauth2", opts.AuthToken) 79 } 80 return u.String(), nil 81 } 82 return remoteAddr, nil 83 } 84 85 // SupportGetRepoComments return true if it supports get repo comments 86 func (n NullDownloader) SupportGetRepoComments() bool { 87 return false 88 }