2024-02-14 23:03:30 +03:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
2024-02-21 18:52:55 +03:00
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2024-02-21 18:52:55 +03:00
|
|
|
var (
|
|
|
|
ErrPRExist = errors.New("Pull request exists")
|
|
|
|
ErrPRNotExist = errors.New("Pull request does not exist")
|
|
|
|
)
|
|
|
|
|
2024-02-14 23:03:30 +03:00
|
|
|
type SourceControl interface {
|
2024-02-21 18:52:55 +03:00
|
|
|
RequestOpen(ctx context.Context, cfg *configcli.Config, branch string, path string, mod modules.Update) error
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func NewSourceControl(system, token string) SourceControl {
|
|
|
|
switch system {
|
|
|
|
case "github":
|
|
|
|
return github.NewGithub(token)
|
|
|
|
case "gitlab":
|
|
|
|
return gitlab.NewGitlab(token)
|
|
|
|
case "gitea":
|
|
|
|
return gitea.NewGitea(token)
|
|
|
|
case "gogs":
|
|
|
|
return gogs.NewGogs(token)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|