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