#8 change Update.

This commit is contained in:
Gorbunov Kirill Andreevich
2024-03-21 15:29:36 +03:00
parent b83cbd9c8e
commit 4ba405adbc
2 changed files with 11 additions and 7 deletions

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
}