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.

git.go 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "context"
  7. "code.gitea.io/gitea/modules/migrations/base"
  8. )
  9. var (
  10. _ base.Downloader = &PlainGitDownloader{}
  11. )
  12. // PlainGitDownloader implements a Downloader interface to clone git from a http/https URL
  13. type PlainGitDownloader struct {
  14. ownerName string
  15. repoName string
  16. remoteURL string
  17. }
  18. // NewPlainGitDownloader creates a git Downloader
  19. func NewPlainGitDownloader(ownerName, repoName, remoteURL string) *PlainGitDownloader {
  20. return &PlainGitDownloader{
  21. ownerName: ownerName,
  22. repoName: repoName,
  23. remoteURL: remoteURL,
  24. }
  25. }
  26. // SetContext set context
  27. func (g *PlainGitDownloader) SetContext(ctx context.Context) {
  28. }
  29. // GetRepoInfo returns a repository information
  30. func (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error) {
  31. // convert github repo to stand Repo
  32. return &base.Repository{
  33. Owner: g.ownerName,
  34. Name: g.repoName,
  35. CloneURL: g.remoteURL,
  36. }, nil
  37. }
  38. // GetTopics returns empty list for plain git repo
  39. func (g *PlainGitDownloader) GetTopics() ([]string, error) {
  40. return []string{}, nil
  41. }
  42. // GetMilestones returns milestones
  43. func (g *PlainGitDownloader) GetMilestones() ([]*base.Milestone, error) {
  44. return nil, ErrNotSupported
  45. }
  46. // GetLabels returns labels
  47. func (g *PlainGitDownloader) GetLabels() ([]*base.Label, error) {
  48. return nil, ErrNotSupported
  49. }
  50. // GetReleases returns releases
  51. func (g *PlainGitDownloader) GetReleases() ([]*base.Release, error) {
  52. return nil, ErrNotSupported
  53. }
  54. // GetIssues returns issues according page and perPage
  55. func (g *PlainGitDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error) {
  56. return nil, false, ErrNotSupported
  57. }
  58. // GetComments returns comments according issueNumber
  59. func (g *PlainGitDownloader) GetComments(issueNumber int64) ([]*base.Comment, error) {
  60. return nil, ErrNotSupported
  61. }
  62. // GetPullRequests returns pull requests according page and perPage
  63. func (g *PlainGitDownloader) GetPullRequests(start, limit int) ([]*base.PullRequest, error) {
  64. return nil, ErrNotSupported
  65. }
  66. // GetReviews returns reviews according issue number
  67. func (g *PlainGitDownloader) GetReviews(issueNumber int64) ([]*base.Review, error) {
  68. return nil, ErrNotSupported
  69. }