#19 change request open

This commit is contained in:
Gorbunov Kirill Andreevich
2024-12-18 21:32:36 +03:00
parent 869f248d24
commit 05e76b7403
2 changed files with 362 additions and 162 deletions

View File

@@ -265,7 +265,7 @@ func Execute(ctx context.Context, log logger.Logger, gitSource source.SourceCont
case "checkupdate":
js, err := json.Marshal(mvs)
fmt.Println(fmt.Sprintf(`Modules get update: %s, %s`, js, err))
case "update":
case "open":
if cliCfg.Path != "" { // update one dep
path = cliCfg.Path
if mod, ok = mvs[path]; !ok {
@@ -294,6 +294,35 @@ func Execute(ctx context.Context, log logger.Logger, gitSource source.SourceCont
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
}
}
case "update":
if cliCfg.Path != "" { // update one dep
path = cliCfg.Path
if mod, ok = mvs[path]; !ok {
log.Fatal(ctx, fmt.Sprintf("For %s update not exist", path))
}
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
for _, branch := range cfg.Branches {
if err := gitSource.RequestUpdate(ctx, branch, path, mod); err != nil {
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
}
}
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
return
}
for _, branch := range cfg.Branches { // update all dep
for path, mod = range mvs {
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
err := gitSource.RequestUpdate(ctx, branch, path, mod)
if err != nil {
if strings.Contains(err.Error(), "already exists") {
log.Debug(ctx, fmt.Sprintf("skip %s, branch already exists", path))
continue
}
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
}
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
}
}
case "close":
if cliCfg.Path != "" { // close one dep
path = cliCfg.Path