You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

null_downloader.go 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package migration
  4. import (
  5. "context"
  6. "net/url"
  7. )
  8. // NullDownloader implements a blank downloader
  9. type NullDownloader struct{}
  10. var _ Downloader = &NullDownloader{}
  11. // SetContext set context
  12. func (n NullDownloader) SetContext(_ context.Context) {}
  13. // GetRepoInfo returns a repository information
  14. func (n NullDownloader) GetRepoInfo() (*Repository, error) {
  15. return nil, ErrNotSupported{Entity: "RepoInfo"}
  16. }
  17. // GetTopics return repository topics
  18. func (n NullDownloader) GetTopics() ([]string, error) {
  19. return nil, ErrNotSupported{Entity: "Topics"}
  20. }
  21. // GetMilestones returns milestones
  22. func (n NullDownloader) GetMilestones() ([]*Milestone, error) {
  23. return nil, ErrNotSupported{Entity: "Milestones"}
  24. }
  25. // GetReleases returns releases
  26. func (n NullDownloader) GetReleases() ([]*Release, error) {
  27. return nil, ErrNotSupported{Entity: "Releases"}
  28. }
  29. // GetLabels returns labels
  30. func (n NullDownloader) GetLabels() ([]*Label, error) {
  31. return nil, ErrNotSupported{Entity: "Labels"}
  32. }
  33. // GetIssues returns issues according start and limit
  34. func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error) {
  35. return nil, false, ErrNotSupported{Entity: "Issues"}
  36. }
  37. // GetComments returns comments of an issue or PR
  38. func (n NullDownloader) GetComments(commentable Commentable) ([]*Comment, bool, error) {
  39. return nil, false, ErrNotSupported{Entity: "Comments"}
  40. }
  41. // GetAllComments returns paginated comments
  42. func (n NullDownloader) GetAllComments(page, perPage int) ([]*Comment, bool, error) {
  43. return nil, false, ErrNotSupported{Entity: "AllComments"}
  44. }
  45. // GetPullRequests returns pull requests according page and perPage
  46. func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error) {
  47. return nil, false, ErrNotSupported{Entity: "PullRequests"}
  48. }
  49. // GetReviews returns pull requests review
  50. func (n NullDownloader) GetReviews(reviewable Reviewable) ([]*Review, error) {
  51. return nil, ErrNotSupported{Entity: "Reviews"}
  52. }
  53. // FormatCloneURL add authentication into remote URLs
  54. func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error) {
  55. if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 {
  56. u, err := url.Parse(remoteAddr)
  57. if err != nil {
  58. return "", err
  59. }
  60. u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword)
  61. if len(opts.AuthToken) > 0 {
  62. u.User = url.UserPassword("oauth2", opts.AuthToken)
  63. }
  64. return u.String(), nil
  65. }
  66. return remoteAddr, nil
  67. }
  68. // SupportGetRepoComments return true if it supports get repo comments
  69. func (n NullDownloader) SupportGetRepoComments() bool {
  70. return false
  71. }