diff --git a/internal/source/gitea/gitea.go b/internal/source/gitea/gitea.go index 09e3624..4900198 100644 --- a/internal/source/gitea/gitea.go +++ b/internal/source/gitea/gitea.go @@ -228,6 +228,8 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m prExist := false var pullId int64 + var targetBranch string + for _, pull := range g.pulls { if strings.Contains(pull.Title, path) && pull.Base.Ref == branch { g.logger.Info(ctx, fmt.Sprintf("don't skip %s since pr exist %s", path, pull.URL)) // todo @@ -238,6 +240,7 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m } prExist = true pullId = pull.ID + targetBranch = pull.Head.Ref } } if !prExist { @@ -281,7 +284,7 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m g.logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err)) } - wtree, headRef, err := g.fetchCheckout(ctx, repo, branch, path, mod) + wtree, headRef, err := g.fetchCheckout(ctx, repo, targetBranch, path, mod) if err != nil { g.logger.Error(ctx, "failed to checkout", err) } @@ -325,9 +328,9 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m g.logger.Info(ctx, fmt.Sprintf("try to push refspec %s", refspec)) if err = repo.PushContext(ctx, &git.PushOptions{ - RefSpecs: []gitconfig.RefSpec{refspec}, - Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password}, - Force: true, + //RefSpecs: []gitconfig.RefSpec{refspec}, + Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password}, + Force: true, }); err != nil { g.logger.Error(ctx, "failed to push repo branch", err) return err @@ -503,7 +506,7 @@ func (g Gitea) fetchCheckout(ctx context.Context, repo *git.Repository, branch, var pullExist bool for _, pull := range g.pulls { - if strings.Contains(pull.Title, path) && strings.Contains(pull.Base.Ref, branch) { + if strings.Contains(pull.Title, path) && (strings.Contains(pull.Base.Ref, branch) || strings.Contains(pull.Head.Ref, branch)) { pullExist = true } // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим }