Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jan 15, 2021
1 parent f8635eb commit 7518582
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
10 changes: 2 additions & 8 deletions modules/migrations/base/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@

package base

import "errors"

var (
// ErrRepoNotCreated returns the error that repository not created
ErrRepoNotCreated = errors.New("repository is not created yet")
)

// ErrNotSupported represents status if a downloader do not supported something.
type ErrNotSupported struct {
}

// ErrNotSupported checks if an error is an ErrNotSupported
// IsErrNotSupported checks if an error is an ErrNotSupported
func IsErrNotSupported(err error) bool {
_, ok := err.(ErrNotSupported)
return ok
}

// Error return error message
func (err ErrNotSupported) Error() string {
return "not supported"
}
17 changes: 13 additions & 4 deletions modules/migrations/base/null_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,63 @@ import (
"net/url"
)

// NullNotifier implements a blank downloader
// NullDownloader implements a blank downloader
type NullDownloader struct {
}

var (
_ Downloader = &NullDownloader{}
)

func (n NullDownloader) SetContext(_ context.Context) {
return
}
// SetContext set context
func (n NullDownloader) SetContext(_ context.Context) {}

// GetRepoInfo returns a repository information
func (n NullDownloader) GetRepoInfo() (*Repository, error) {
return nil, &ErrNotSupported{}
}

// GetTopics return gitlab topics
func (n NullDownloader) GetTopics() ([]string, error) {
return nil, &ErrNotSupported{}
}

// GetMilestones returns milestones
func (n NullDownloader) GetMilestones() ([]*Milestone, error) {
return nil, &ErrNotSupported{}
}

// GetReleases returns releases
func (n NullDownloader) GetReleases() ([]*Release, error) {
return nil, &ErrNotSupported{}
}

// GetLabels returns labels
func (n NullDownloader) GetLabels() ([]*Label, error) {
return nil, &ErrNotSupported{}
}

// GetIssues returns issues according start and limit
func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error) {
return nil, false, &ErrNotSupported{}
}

// GetComments returns comments according issueNumber
func (n NullDownloader) GetComments(issueNumber int64) ([]*Comment, error) {
return nil, &ErrNotSupported{}
}

// GetPullRequests returns pull requests according page and perPage
func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error) {
return nil, false, &ErrNotSupported{}
}

// GetReviews returns pull requests review
func (n NullDownloader) GetReviews(pullRequestNumber int64) ([]*Review, error) {
return nil, &ErrNotSupported{}
}

// FormatGitURL return func to add authentification into remote URLs
func (n NullDownloader) FormatGitURL() func(opts MigrateOptions, remoteAddr string) (string, error) {
return func(opts MigrateOptions, remoteAddr string) (string, error) {
if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 {
Expand Down
4 changes: 3 additions & 1 deletion modules/migrations/gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type GogsDownloader struct {
password string
}

// SetContext set context
func (g *GogsDownloader) SetContext(ctx context.Context) {
g.ctx = ctx
}
Expand Down Expand Up @@ -206,7 +207,8 @@ func (g *GogsDownloader) GetComments(issueNumber int64) ([]*base.Comment, error)
return allComments, nil
}

func (n GogsDownloader) FormatGitURL() func(opts MigrateOptions, remoteAddr string) (string, error) {
// FormatGitURL return func to add authentification into remote URLs
func (g GogsDownloader) FormatGitURL() func(opts MigrateOptions, remoteAddr string) (string, error) {
return func(opts MigrateOptions, remoteAddr string) (string, error) {
if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 {
u, err := url.Parse(remoteAddr)
Expand Down

0 comments on commit 7518582

Please sign in to comment.