code.gitea.io/gitea@v1.21.7/services/migrations/git.go (about)

     1  // Copyright 2019 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package migrations
     5  
     6  import (
     7  	"context"
     8  
     9  	base "code.gitea.io/gitea/modules/migration"
    10  )
    11  
    12  var _ base.Downloader = &PlainGitDownloader{}
    13  
    14  // PlainGitDownloader implements a Downloader interface to clone git from a http/https URL
    15  type PlainGitDownloader struct {
    16  	base.NullDownloader
    17  	ownerName string
    18  	repoName  string
    19  	remoteURL string
    20  }
    21  
    22  // NewPlainGitDownloader creates a git Downloader
    23  func NewPlainGitDownloader(ownerName, repoName, remoteURL string) *PlainGitDownloader {
    24  	return &PlainGitDownloader{
    25  		ownerName: ownerName,
    26  		repoName:  repoName,
    27  		remoteURL: remoteURL,
    28  	}
    29  }
    30  
    31  // SetContext set context
    32  func (g *PlainGitDownloader) SetContext(ctx context.Context) {
    33  }
    34  
    35  // GetRepoInfo returns a repository information
    36  func (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error) {
    37  	// convert github repo to stand Repo
    38  	return &base.Repository{
    39  		Owner:    g.ownerName,
    40  		Name:     g.repoName,
    41  		CloneURL: g.remoteURL,
    42  	}, nil
    43  }
    44  
    45  // GetTopics return empty string slice
    46  func (g PlainGitDownloader) GetTopics() ([]string, error) {
    47  	return []string{}, nil
    48  }