#8 skip path if branch exists #12

Merged
vtolstov merged 90 commits from kgorbunov/pkgdash:master into master 2024-04-03 08:28:17 +03:00
2 changed files with 11 additions and 7 deletions
Showing only changes of commit 4ba405adbc - Show all commits

View File

@ -157,7 +157,7 @@ func main() {
OnUpdate: func(u modules.Update) {
var modpath string // new mod path with major
if u.Err != nil {
logger.Error(ctx, "%s: failed: %v", u.Module.Path, u.Err)
logger.Error(ctx, fmt.Sprintf("%s: failed: %v", u.Module.Path, u.Err))
return
}
modpath = u.Module.Path
@ -215,7 +215,7 @@ 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)
logger.Debugf(ctx, fmt.Sprintf("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" {
@ -226,7 +226,7 @@ func main() {
}
logger.Error(ctx, fmt.Sprintf("failed to create pr: %v", err))
}
logger.Debugf(ctx, "Update successful for %s", pathMod)
logger.Debugf(ctx, fmt.Sprintf("Update successful for %s", pathMod))
}
}
//err = gitSource.RequestClose(ctx, "master", "modernc.org/ccgo/v4")

View File

@ -63,7 +63,7 @@ type giteaPull struct {
}
func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod modules.Update) error {
logger.Debugf(ctx, "RequestOpen start, mod title: %s", path)
logger.Debugf(ctx, fmt.Sprintf("RequestOpen start, mod title: %s", path))
var buf []byte
var err error
@ -112,6 +112,7 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
refIter, err := repo.Branches() //получение веток
if err != nil {
logger.Fatal(ctx, fmt.Sprintf("failed to get branches: %v", err))
return err
}
for {
ref, err := refIter.Next()
@ -127,9 +128,10 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
if headRef == nil {
logger.Fatal(ctx, "failed to get repo branch head")
return err
} // Не получили нужную ветку
logger.Info(ctx, "repo head %s", headRef)
logger.Info(ctx, fmt.Sprintf("repo head %s", headRef))
wtree, err := repo.Worktree() //todo вроде рабочее дерево не нужно
if err != nil {
@ -279,7 +281,7 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
}
func (g *Gitea) RequestClose(ctx context.Context, branch string, path string) error {
logger.Debugf(ctx, "RequestClose start, mod title: %s", path)
logger.Debugf(ctx, fmt.Sprintf("RequestClose start, mod title: %s", path))
pulls, err := GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Token)
if err != nil {
@ -317,7 +319,7 @@ func (g *Gitea) RequestClose(ctx context.Context, branch string, path string) er
}
func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, mod modules.Update) error {
logger.Debugf(ctx, "RequestUpdate start, mod title: %s", path)
logger.Debugf(ctx, fmt.Sprintf("RequestUpdate start, mod title: %s", path))
pulls, err := GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Token)
if err != nil {
@ -342,6 +344,8 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m
continue //думаю что если не можем удалить ветку не стоит заканчивать работу, а перейти к следующей итерации
}
logger.Info(ctx, fmt.Sprintf("Old pr %s successful delete", pull.Head.Ref))
} else {
return nil
}
prExist = true
}