mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-06 22:08:46 +00:00
* fix(deps): update module github.com/petergtz/pegomock/v3 to v4 in go.mod * remove pegomock generate m option, which is not support after v4 * make regen-mocks * replace pegomock v4 primitive eq/matchers * convert pegomock v4 Eq/Any matchers * remove custom models.Repo matcher * pegomock v4 cannot use result method args ref https://github.com/petergtz/pegomock/issues/123 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package vcs
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/runatlantis/atlantis/server/events/models"
|
|
)
|
|
|
|
//go:generate pegomock generate --package mocks -o mocks/mock_pull_req_status_fetcher.go PullReqStatusFetcher
|
|
|
|
type PullReqStatusFetcher interface {
|
|
FetchPullStatus(pull models.PullRequest) (models.PullReqStatus, error)
|
|
}
|
|
|
|
type pullReqStatusFetcher struct {
|
|
client Client
|
|
vcsStatusName string
|
|
}
|
|
|
|
func NewPullReqStatusFetcher(client Client, vcsStatusName string) PullReqStatusFetcher {
|
|
return &pullReqStatusFetcher{
|
|
client: client,
|
|
vcsStatusName: vcsStatusName,
|
|
}
|
|
}
|
|
|
|
func (f *pullReqStatusFetcher) FetchPullStatus(pull models.PullRequest) (pullStatus models.PullReqStatus, err error) {
|
|
approvalStatus, err := f.client.PullIsApproved(pull.BaseRepo, pull)
|
|
if err != nil {
|
|
return pullStatus, errors.Wrapf(err, "fetching pull approval status for repo: %s, and pull number: %d", pull.BaseRepo.FullName, pull.Num)
|
|
}
|
|
|
|
mergeable, err := f.client.PullIsMergeable(pull.BaseRepo, pull, f.vcsStatusName)
|
|
if err != nil {
|
|
return pullStatus, errors.Wrapf(err, "fetching mergeability status for repo: %s, and pull number: %d", pull.BaseRepo.FullName, pull.Num)
|
|
}
|
|
|
|
return models.PullReqStatus{
|
|
ApprovalStatus: approvalStatus,
|
|
Mergeable: mergeable,
|
|
}, err
|
|
}
|