#8 Finished the update I need to redo the call of these methods.
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/configcli"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/modules"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/source"
|
||||
"github.com/go-git/go-git/v5"
|
||||
gitconfig "github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
@@ -29,6 +30,8 @@ import (
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"golang.org/x/mod/modfile"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// https://docs.github.com/ru/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
@@ -62,6 +65,7 @@ type Data struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Start...")
|
||||
var err error
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -71,14 +75,13 @@ func main() {
|
||||
logger.Errorf(ctx, "logger init error: %v", err)
|
||||
}
|
||||
|
||||
cfg := &configcli.Config{}
|
||||
cfg := configcli.NewConfig()
|
||||
|
||||
if err = config.Load(ctx,
|
||||
[]config.Config{
|
||||
config.NewConfig(
|
||||
config.Struct(cfg),
|
||||
),
|
||||
|
||||
envconfig.NewConfig(
|
||||
config.Struct(cfg),
|
||||
),
|
||||
@@ -99,9 +102,23 @@ func main() {
|
||||
if err = c.Load(ctx, config.LoadOverride(true)); err != nil {
|
||||
logger.Fatalf(ctx, "failed to load config: %v", err)
|
||||
}
|
||||
logger.Infof(ctx, "c: %v", c)
|
||||
}
|
||||
}
|
||||
|
||||
file, err := os.Open(".gitea/pkgdashcli.yaml")
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "file open: %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
d := yaml.NewDecoder(file)
|
||||
if err = d.Decode(&cfg); err != nil {
|
||||
logger.Fatalf(ctx, "Decode err: %s", d)
|
||||
}
|
||||
|
||||
logger.Infof(ctx, "Load config... %s", cfg)
|
||||
|
||||
if cfg.PullRequestBody == "" {
|
||||
cfg.PullRequestBody = DefaultPullRequestBody
|
||||
}
|
||||
@@ -149,23 +166,45 @@ func main() {
|
||||
|
||||
modules.Updates(updateOptions)
|
||||
|
||||
var repoGit, tokenGit string
|
||||
/*var repoGit, tokenGit string // nameGit = gitea, repoGit = pkgdash, tokenGit = {xxx}, machine??
|
||||
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")
|
||||
logger.Fatalf(ctx, "pkgdash/main failed to get repo management")
|
||||
}
|
||||
}
|
||||
_ = tokenGit
|
||||
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "pkgdash/main can t get info user: %s", err)
|
||||
} else {
|
||||
n, err := netrc.Parse(filepath.Join(usr.HomeDir, ".netrc"))
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "pkgdash/main can t parse .netrc: %s", err)
|
||||
}
|
||||
tokenGit = n.Machine(repoGit).Get("password")
|
||||
}
|
||||
|
||||
switch repoGit {
|
||||
case "gitea":
|
||||
for _, branch := range cfg.Branches {
|
||||
err = giteaPullRequest(ctx, cfg, branch, mvs)
|
||||
}
|
||||
}*/
|
||||
|
||||
logger.Infof(ctx, "cfg: %v", cfg)
|
||||
|
||||
gitSource := source.NewSourceControl(*cfg)
|
||||
for _, branch := range cfg.Branches {
|
||||
for pathMod, mod := range mvs {
|
||||
err = gitSource.RequestOpen(ctx, branch, pathMod, mod)
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to create pr: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user