#19 #20

Closed
kgorbunov wants to merge 112 commits from kgorbunov/pkgdash:#19 into master
Showing only changes of commit 950055d525 - Show all commits

View File

@ -228,6 +228,8 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m
prExist := false prExist := false
var pullId int64 var pullId int64
var targetBranch string
for _, pull := range g.pulls { for _, pull := range g.pulls {
if strings.Contains(pull.Title, path) && pull.Base.Ref == branch { 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 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 prExist = true
pullId = pull.ID pullId = pull.ID
targetBranch = pull.Head.Ref
} }
} }
if !prExist { 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)) 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 { if err != nil {
g.logger.Error(ctx, "failed to checkout", err) g.logger.Error(ctx, "failed to checkout", err)
} }
@ -325,7 +328,7 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m
g.logger.Info(ctx, fmt.Sprintf("try to push refspec %s", refspec)) g.logger.Info(ctx, fmt.Sprintf("try to push refspec %s", refspec))
if err = repo.PushContext(ctx, &git.PushOptions{ if err = repo.PushContext(ctx, &git.PushOptions{
RefSpecs: []gitconfig.RefSpec{refspec}, //RefSpecs: []gitconfig.RefSpec{refspec},
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password}, Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
Force: true, Force: true,
}); err != nil { }); err != nil {
@ -503,7 +506,7 @@ func (g Gitea) fetchCheckout(ctx context.Context, repo *git.Repository, branch,
var pullExist bool var pullExist bool
for _, pull := range g.pulls { 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 pullExist = true
} // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим } // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим
} }