#8 Finalization RequestUpdate and RequestClose.
This commit is contained in:
@@ -201,7 +201,7 @@ func main() {
|
||||
|
||||
defer func() {
|
||||
if err := cw.Stop(); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
logger.Error(ctx, err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import (
|
||||
fileconfig "go.unistack.org/micro-config-file/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/logger/slog"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"golang.org/x/mod/modfile"
|
||||
"golang.org/x/mod/semver"
|
||||
@@ -71,7 +72,9 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
if err = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3)); err != nil {
|
||||
logger.DefaultLogger = slog.NewLogger()
|
||||
|
||||
if err = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3), logger.WithLevel(logger.DebugLevel)); err != nil {
|
||||
logger.Error(ctx, "logger init error: %v", err)
|
||||
}
|
||||
|
||||
@@ -147,10 +150,10 @@ func main() {
|
||||
mvs := make(map[string]modules.Update)
|
||||
|
||||
updateOptions := modules.UpdateOptions{
|
||||
Pre: false,
|
||||
Major: false,
|
||||
UpMajor: false,
|
||||
Cached: true,
|
||||
Pre: cfg.UpdateOpt.Pre,
|
||||
Major: cfg.UpdateOpt.Major,
|
||||
UpMajor: cfg.UpdateOpt.UpMajor,
|
||||
Cached: cfg.UpdateOpt.Cached,
|
||||
OnUpdate: func(u modules.Update) {
|
||||
var modpath string // new mod path with major
|
||||
if u.Err != nil {
|
||||
@@ -212,17 +215,23 @@ func main() {
|
||||
gitSource := source.NewSourceControl(*cfg)
|
||||
for _, branch := range cfg.Branches {
|
||||
for pathMod, mod := range mvs {
|
||||
logger.Debugf(ctx, "Start update %s from %s to %s", pathMod, mod.Module.Version, mod.Version)
|
||||
err = gitSource.RequestOpen(ctx, branch, pathMod, mod)
|
||||
if err != nil {
|
||||
if err.Error() == "pull request exists" {
|
||||
err = gitSource.RequestUpdate(ctx, branch, pathMod, mod)
|
||||
if err != nil {
|
||||
logger.Error(ctx, "Update PR error: %s", err)
|
||||
}
|
||||
}
|
||||
logger.Error(ctx, "failed to create pr: %v", err)
|
||||
}
|
||||
logger.Info(ctx, "PR create for %s - %s", pathMod, mod.Version)
|
||||
logger.Debugf(ctx, "Update successful for %s", pathMod)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, "failed to create pr: %v", err)
|
||||
}
|
||||
//err = gitSource.RequestClose(ctx, "master", "modernc.org/ccgo/v4")
|
||||
logger.Info(ctx, "Pkgdash successfully updated dependencies")
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
func getRepoMgmt() string {
|
||||
|
Reference in New Issue
Block a user