36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
|
package source
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"go.unistack.org/micro/v3/logger"
|
||
|
"go.unistack.org/pkgdash/internal/configcli"
|
||
|
"go.unistack.org/pkgdash/internal/modules"
|
||
|
"go.unistack.org/pkgdash/internal/source/gitea"
|
||
|
"go.unistack.org/pkgdash/internal/source/github"
|
||
|
"go.unistack.org/pkgdash/internal/source/gitlab"
|
||
|
"go.unistack.org/pkgdash/internal/source/gogs"
|
||
|
)
|
||
|
|
||
|
type SourceControl interface {
|
||
|
Name() string
|
||
|
RequestOpen(ctx context.Context, branch string, path string, mod modules.Update) error
|
||
|
RequestClose(ctx context.Context, branch string, path string) error
|
||
|
RequestUpdate(ctx context.Context, branch string, path string, mod modules.Update) error
|
||
|
RequestList(ctx context.Context, branch string) (map[string]string, error)
|
||
|
}
|
||
|
|
||
|
func NewSourceControl(cfg configcli.Config, log logger.Logger) SourceControl {
|
||
|
switch cfg.Source.TypeGit {
|
||
|
case "github":
|
||
|
return github.NewGithub(cfg, log)
|
||
|
case "gitlab":
|
||
|
return gitlab.NewGitlab(cfg, log)
|
||
|
case "gitea":
|
||
|
return gitea.NewGitea(cfg, log)
|
||
|
case "gogs":
|
||
|
return gogs.NewGogs(cfg, log)
|
||
|
}
|
||
|
return nil
|
||
|
}
|