#8 implement interface Source and methods for gitea without Update

This commit is contained in:
Gorbunov Kirill Andreevich
2024-02-14 23:03:30 +03:00
parent d56b389572
commit a1cb049afa
7 changed files with 716 additions and 12 deletions

View File

@@ -15,6 +15,7 @@ import (
"text/template"
"time"
"git.unistack.org/unistack-org/pkgdash/internal/configcli"
"git.unistack.org/unistack-org/pkgdash/internal/modules"
"github.com/go-git/go-git/v5"
gitconfig "github.com/go-git/go-git/v5/config"
@@ -37,12 +38,6 @@ var (
DefaultPullRequestBody = `Bumps {{.Name}} from {{.VersionOld}} to {{.VersionNew}}`
)
type Config struct {
PullRequestTitle string `json:"pull_request_title" yaml:"pull_request_title"`
PullRequestBody string `json:"pull_request_body" yaml:"pull_request_body"`
Branches []string `json:"branches" yaml:"branches"`
}
var (
configFiles = []string{
"dependabot.yml",
@@ -76,7 +71,7 @@ func main() {
logger.Errorf(ctx, "logger init error: %v", err)
}
cfg := &Config{}
cfg := &configcli.Config{}
if err = config.Load(ctx,
[]config.Config{
@@ -154,12 +149,19 @@ func main() {
modules.Updates(updateOptions)
repoMgmt := getRepoMgmt()
if repoMgmt == "unknown" {
logger.Fatalf(ctx, "failed to get repo management")
var repoGit, tokenGit string
if cfg.Source != nil {
repoGit = cfg.Source.TypeGit
tokenGit = cfg.Source.Token
} else {
repoGit = getRepoMgmt()
if repoGit == "unknown" {
logger.Fatalf(ctx, "failed to get repo management")
}
}
_ = tokenGit
switch repoMgmt {
switch repoGit {
case "gitea":
for _, branch := range cfg.Branches {
err = giteaPullRequest(ctx, cfg, branch, mvs)
@@ -192,7 +194,7 @@ func getRepoMgmt() string {
}
}
func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[string]modules.Update) error {
func giteaPullRequest(ctx context.Context, cfg *configcli.Config, branch string, mods map[string]modules.Update) error {
envAPIURL := os.Getenv("GITHUB_API_URL")
envREPOSITORY := os.Getenv("GITHUB_REPOSITORY")
envTOKEN := os.Getenv("GITHUB_TOKEN")