2024-02-14 23:03:30 +03:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
2024-02-21 18:52:55 +03:00
|
|
|
"context"
|
|
|
|
|
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/configcli"
|
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/modules"
|
2024-02-14 23:03:30 +03:00
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/source/gitea"
|
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/source/github"
|
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/source/gitlab"
|
|
|
|
"git.unistack.org/unistack-org/pkgdash/internal/source/gogs"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SourceControl interface {
|
2024-03-15 21:18:58 +03:00
|
|
|
RequestOpen(ctx context.Context, branch string, path string, mod modules.Update) error
|
2024-02-21 18:52:55 +03:00
|
|
|
RequestClose(ctx context.Context, cfg *configcli.Config, branch string, path string) error
|
|
|
|
RequestUpdate(ctx context.Context, cfg *configcli.Config, branch string, path string, mod modules.Update) error
|
2024-02-14 23:03:30 +03:00
|
|
|
}
|
|
|
|
|
2024-03-15 21:18:58 +03:00
|
|
|
func NewSourceControl(cfg configcli.Config) SourceControl {
|
|
|
|
switch cfg.Source.TypeGit {
|
2024-02-14 23:03:30 +03:00
|
|
|
case "github":
|
2024-03-15 21:18:58 +03:00
|
|
|
return github.NewGithub(cfg)
|
2024-02-14 23:03:30 +03:00
|
|
|
case "gitlab":
|
2024-03-15 21:18:58 +03:00
|
|
|
return gitlab.NewGitlab(cfg)
|
2024-02-14 23:03:30 +03:00
|
|
|
case "gitea":
|
2024-03-15 21:18:58 +03:00
|
|
|
return gitea.NewGitea(cfg)
|
2024-02-14 23:03:30 +03:00
|
|
|
case "gogs":
|
2024-03-15 21:18:58 +03:00
|
|
|
return gogs.NewGogs(cfg)
|
2024-02-14 23:03:30 +03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|