mirror of
https://github.com/harness/drone.git
synced 2025-05-21 03:20:15 +08:00
feat: [PIPE-22454]: add PR metadata in get/list PR API response (#2912)
* add PR metadata in PR API response
This commit is contained in:
parent
0ca7e83e34
commit
0db33abeb1
@ -32,6 +32,7 @@ func (c *Controller) Find(
|
||||
session *auth.Session,
|
||||
repoRef string,
|
||||
pullreqNum int64,
|
||||
options types.PullReqMetadataOptions,
|
||||
) (*types.PullReq, error) {
|
||||
if pullreqNum <= 0 {
|
||||
return nil, usererror.BadRequest("A valid pull request number must be provided.")
|
||||
@ -52,6 +53,10 @@ func (c *Controller) Find(
|
||||
return nil, fmt.Errorf("failed to backfill labels assigned to pull request: %w", err)
|
||||
}
|
||||
|
||||
if err := c.pullreqListService.BackfillMetadataForPullReq(ctx, repo, pr, options); err != nil {
|
||||
return nil, fmt.Errorf("failed to backfill pull request metadata: %w", err)
|
||||
}
|
||||
|
||||
if err := c.pullreqListService.BackfillStats(ctx, pr); err != nil {
|
||||
log.Ctx(ctx).Warn().Err(err).Msg("failed to backfill PR stats")
|
||||
}
|
||||
@ -59,7 +64,7 @@ func (c *Controller) Find(
|
||||
return pr, nil
|
||||
}
|
||||
|
||||
// Find returns a pull request from the provided repository.
|
||||
// FindByBranches returns a pull request from the provided branch pair.
|
||||
func (c *Controller) FindByBranches(
|
||||
ctx context.Context,
|
||||
session *auth.Session,
|
||||
@ -67,6 +72,7 @@ func (c *Controller) FindByBranches(
|
||||
sourceRepoRef,
|
||||
sourceBranch,
|
||||
targetBranch string,
|
||||
options types.PullReqMetadataOptions,
|
||||
) (*types.PullReq, error) {
|
||||
if sourceBranch == "" || targetBranch == "" {
|
||||
return nil, usererror.BadRequest("A valid source/target branch must be provided.")
|
||||
@ -103,5 +109,9 @@ func (c *Controller) FindByBranches(
|
||||
return nil, usererror.ErrNotFound
|
||||
}
|
||||
|
||||
if err := c.pullreqListService.BackfillMetadataForPullReq(ctx, targetRepo, prs[0], options); err != nil {
|
||||
return nil, fmt.Errorf("failed to backfill pull request metadata: %w", err)
|
||||
}
|
||||
|
||||
return prs[0], nil
|
||||
}
|
||||
|
@ -81,6 +81,10 @@ func (c *Controller) List(
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if err := c.pullreqListService.BackfillMetadataForRepo(ctx, repo, list, filter.PullReqMetadataOptions); err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to backfill metadata for pull requests: %w", err)
|
||||
}
|
||||
|
||||
for _, pr := range list {
|
||||
if err := c.pullreqListService.BackfillStats(ctx, pr); err != nil {
|
||||
log.Ctx(ctx).Warn().Err(err).Msg("failed to backfill PR stats")
|
||||
|
@ -40,7 +40,13 @@ func HandleFind(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
pr, err := pullreqCtrl.Find(ctx, session, repoRef, pullreqNumber)
|
||||
options, err := request.ParsePullReqMetadataOptions(r)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
pr, err := pullreqCtrl.Find(ctx, session, repoRef, pullreqNumber, options)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
@ -50,7 +56,7 @@ func HandleFind(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// HandleFind returns a http.HandlerFunc that finds a pull request.
|
||||
// HandleFindByBranches returns a http.HandlerFunc that finds a pull request from the provided branch pair.
|
||||
func HandleFindByBranches(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
@ -76,7 +82,13 @@ func HandleFindByBranches(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
pr, err := pullreqCtrl.FindByBranches(ctx, session, repoRef, sourceRepoRef, sourceBranch, targetBranch)
|
||||
options, err := request.ParsePullReqMetadataOptions(r)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
pr, err := pullreqCtrl.FindByBranches(ctx, session, repoRef, sourceRepoRef, sourceBranch, targetBranch, options)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"github.com/harness/gitness/app/api/controller/pullreq"
|
||||
"github.com/harness/gitness/app/api/render"
|
||||
"github.com/harness/gitness/app/api/request"
|
||||
"github.com/harness/gitness/types"
|
||||
)
|
||||
|
||||
// HandleMetadata returns a http.HandlerFunc that returns PR metadata.
|
||||
@ -40,7 +41,7 @@ func HandleMetadata(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
pr, err := pullreqCtrl.Find(ctx, session, repoRef, pullreqNumber)
|
||||
pr, err := pullreqCtrl.Find(ctx, session, repoRef, pullreqNumber, types.PullReqMetadataOptions{})
|
||||
if err != nil {
|
||||
render.TranslatedUserError(ctx, w, err)
|
||||
return
|
||||
|
@ -504,7 +504,8 @@ func pullReqOperations(reflector *openapi3.Reflector) {
|
||||
QueryParameterPage, QueryParameterLimit,
|
||||
QueryParameterLabelID, QueryParameterValueID,
|
||||
queryParameterAuthorID, queryParameterCommenterID, queryParameterMentionedID,
|
||||
queryParameterReviewerID, queryParameterReviewDecision)
|
||||
queryParameterReviewerID, queryParameterReviewDecision,
|
||||
queryParameterIncludeChecks, queryParameterIncludeRules)
|
||||
_ = reflector.SetRequest(&listPullReq, new(listPullReqRequest), http.MethodGet)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new([]types.PullReq), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new(usererror.Error), http.StatusBadRequest)
|
||||
@ -516,6 +517,7 @@ func pullReqOperations(reflector *openapi3.Reflector) {
|
||||
getPullReq := openapi3.Operation{}
|
||||
getPullReq.WithTags("pullreq")
|
||||
getPullReq.WithMapOfAnything(map[string]interface{}{"operationId": "getPullReq"})
|
||||
getPullReq.WithParameters(queryParameterIncludeChecks, queryParameterIncludeRules)
|
||||
_ = reflector.SetRequest(&getPullReq, new(getPullReqRequest), http.MethodGet)
|
||||
_ = reflector.SetJSONResponse(&getPullReq, new(types.PullReq), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&getPullReq, new(usererror.Error), http.StatusBadRequest)
|
||||
@ -527,7 +529,8 @@ func pullReqOperations(reflector *openapi3.Reflector) {
|
||||
getPullReqByBranches := openapi3.Operation{}
|
||||
getPullReqByBranches.WithTags("pullreq")
|
||||
getPullReqByBranches.WithMapOfAnything(map[string]interface{}{"operationId": "getPullReqByBranches"})
|
||||
getPullReqByBranches.WithParameters(queryParameterSourceRepoRefPullRequest)
|
||||
getPullReqByBranches.WithParameters(queryParameterSourceRepoRefPullRequest,
|
||||
queryParameterIncludeChecks, queryParameterIncludeRules)
|
||||
_ = reflector.SetRequest(&getPullReqByBranches, new(getPullReqByBranchesRequest), http.MethodGet)
|
||||
_ = reflector.SetJSONResponse(&getPullReqByBranches, new(types.PullReq), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&getPullReqByBranches, new(usererror.Error), http.StatusBadRequest)
|
||||
|
@ -600,9 +600,10 @@ func spaceOperations(reflector *openapi3.Reflector) {
|
||||
QueryParameterLimit,
|
||||
QueryParameterLabelID, QueryParameterValueID,
|
||||
queryParameterAuthorID, queryParameterCommenterID, queryParameterMentionedID,
|
||||
queryParameterReviewerID, queryParameterReviewDecision)
|
||||
queryParameterReviewerID, queryParameterReviewDecision,
|
||||
queryParameterIncludeChecks, queryParameterIncludeRules)
|
||||
_ = reflector.SetRequest(&listPullReq, new(listPullReqRequest), http.MethodGet)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new([]types.PullReq), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new([]types.PullReqRepo), http.StatusOK)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new(usererror.Error), http.StatusBadRequest)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new(usererror.Error), http.StatusInternalServerError)
|
||||
_ = reflector.SetJSONResponse(&listPullReq, new(usererror.Error), http.StatusUnauthorized)
|
||||
|
@ -109,6 +109,23 @@ func parseReviewDecisions(r *http.Request) []enum.PullReqReviewDecision {
|
||||
return reviewDecisions
|
||||
}
|
||||
|
||||
func ParsePullReqMetadataOptions(r *http.Request) (types.PullReqMetadataOptions, error) {
|
||||
includeChecks, err := GetIncludeChecksFromQueryOrDefault(r, false)
|
||||
if err != nil {
|
||||
return types.PullReqMetadataOptions{}, err
|
||||
}
|
||||
|
||||
includeRules, err := GetIncludeRulesFromQueryOrDefault(r, false)
|
||||
if err != nil {
|
||||
return types.PullReqMetadataOptions{}, err
|
||||
}
|
||||
|
||||
return types.PullReqMetadataOptions{
|
||||
IncludeChecks: includeChecks,
|
||||
IncludeRules: includeRules,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ParsePullReqFilter extracts the pull request query parameter from the url.
|
||||
func ParsePullReqFilter(r *http.Request) (*types.PullReqFilter, error) {
|
||||
createdBy, err := QueryParamListAsPositiveInt64(r, QueryParamCreatedBy)
|
||||
@ -170,28 +187,34 @@ func ParsePullReqFilter(r *http.Request) (*types.PullReqFilter, error) {
|
||||
return nil, fmt.Errorf("encountered error parsing mentioned ID filter: %w", err)
|
||||
}
|
||||
|
||||
metadataOptions, err := ParsePullReqMetadataOptions(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.PullReqFilter{
|
||||
Page: ParsePage(r),
|
||||
Size: ParseLimit(r),
|
||||
Query: ParseQuery(r),
|
||||
CreatedBy: createdBy,
|
||||
SourceRepoRef: r.URL.Query().Get("source_repo_ref"),
|
||||
SourceBranch: r.URL.Query().Get("source_branch"),
|
||||
TargetBranch: r.URL.Query().Get("target_branch"),
|
||||
States: parsePullReqStates(r),
|
||||
Sort: ParseSortPullReq(r),
|
||||
Order: ParseOrder(r),
|
||||
LabelID: labelID,
|
||||
ValueID: valueID,
|
||||
AuthorID: authorID,
|
||||
CommenterID: commenterID,
|
||||
ReviewerID: reviewerID,
|
||||
ReviewDecisions: reviewDecisions,
|
||||
MentionedID: mentionedID,
|
||||
ExcludeDescription: excludeDescription,
|
||||
CreatedFilter: createdFilter,
|
||||
UpdatedFilter: updatedFilter,
|
||||
EditedFilter: editedFilter,
|
||||
Page: ParsePage(r),
|
||||
Size: ParseLimit(r),
|
||||
Query: ParseQuery(r),
|
||||
CreatedBy: createdBy,
|
||||
SourceRepoRef: r.URL.Query().Get("source_repo_ref"),
|
||||
SourceBranch: r.URL.Query().Get("source_branch"),
|
||||
TargetBranch: r.URL.Query().Get("target_branch"),
|
||||
States: parsePullReqStates(r),
|
||||
Sort: ParseSortPullReq(r),
|
||||
Order: ParseOrder(r),
|
||||
LabelID: labelID,
|
||||
ValueID: valueID,
|
||||
AuthorID: authorID,
|
||||
CommenterID: commenterID,
|
||||
ReviewerID: reviewerID,
|
||||
ReviewDecisions: reviewDecisions,
|
||||
MentionedID: mentionedID,
|
||||
ExcludeDescription: excludeDescription,
|
||||
CreatedFilter: createdFilter,
|
||||
UpdatedFilter: updatedFilter,
|
||||
EditedFilter: editedFilter,
|
||||
PullReqMetadataOptions: metadataOptions,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"github.com/harness/gitness/app/auth"
|
||||
"github.com/harness/gitness/app/auth/authz"
|
||||
"github.com/harness/gitness/app/services/label"
|
||||
"github.com/harness/gitness/app/services/protection"
|
||||
"github.com/harness/gitness/app/store"
|
||||
"github.com/harness/gitness/errors"
|
||||
"github.com/harness/gitness/git"
|
||||
@ -30,18 +31,21 @@ import (
|
||||
"github.com/harness/gitness/types"
|
||||
"github.com/harness/gitness/types/enum"
|
||||
|
||||
"github.com/gotidy/ptr"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type ListService struct {
|
||||
tx dbtx.Transactor
|
||||
git git.Interface
|
||||
authorizer authz.Authorizer
|
||||
spaceStore store.SpaceStore
|
||||
repoStore store.RepoStore
|
||||
repoGitInfoCache store.RepoGitInfoCache
|
||||
pullreqStore store.PullReqStore
|
||||
labelSvc *label.Service
|
||||
tx dbtx.Transactor
|
||||
git git.Interface
|
||||
authorizer authz.Authorizer
|
||||
spaceStore store.SpaceStore
|
||||
repoStore store.RepoStore
|
||||
repoGitInfoCache store.RepoGitInfoCache
|
||||
pullreqStore store.PullReqStore
|
||||
checkStore store.CheckStore
|
||||
labelSvc *label.Service
|
||||
protectionManager *protection.Manager
|
||||
}
|
||||
|
||||
func NewListService(
|
||||
@ -52,17 +56,21 @@ func NewListService(
|
||||
repoStore store.RepoStore,
|
||||
repoGitInfoCache store.RepoGitInfoCache,
|
||||
pullreqStore store.PullReqStore,
|
||||
checkStore store.CheckStore,
|
||||
labelSvc *label.Service,
|
||||
protectionManager *protection.Manager,
|
||||
) *ListService {
|
||||
return &ListService{
|
||||
tx: tx,
|
||||
git: git,
|
||||
authorizer: authorizer,
|
||||
spaceStore: spaceStore,
|
||||
repoStore: repoStore,
|
||||
repoGitInfoCache: repoGitInfoCache,
|
||||
pullreqStore: pullreqStore,
|
||||
labelSvc: labelSvc,
|
||||
tx: tx,
|
||||
git: git,
|
||||
authorizer: authorizer,
|
||||
spaceStore: spaceStore,
|
||||
repoStore: repoStore,
|
||||
repoGitInfoCache: repoGitInfoCache,
|
||||
pullreqStore: pullreqStore,
|
||||
checkStore: checkStore,
|
||||
labelSvc: labelSvc,
|
||||
protectionManager: protectionManager,
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,6 +174,10 @@ func (c *ListService) ListForSpace(
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.BackfillMetadata(ctx, response, filter.PullReqMetadataOptions); err != nil {
|
||||
return nil, fmt.Errorf("failed to backfill metadata: %w", err)
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@ -228,3 +240,188 @@ func (c *ListService) BackfillStats(ctx context.Context, pr *types.PullReq) erro
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackfillChecks collects the check metadata for the provided list of pull requests.
|
||||
func (c *ListService) BackfillChecks(
|
||||
ctx context.Context,
|
||||
list []types.PullReqRepo,
|
||||
) error {
|
||||
// prepare list of commit SHAs per repository
|
||||
|
||||
repoCommitSHAs := make(map[int64][]string)
|
||||
for _, entry := range list {
|
||||
repoID := entry.Repository.ID
|
||||
commitSHAs := repoCommitSHAs[repoID]
|
||||
repoCommitSHAs[repoID] = append(commitSHAs, entry.PullRequest.SourceSHA)
|
||||
}
|
||||
|
||||
// fetch checks for every repository
|
||||
|
||||
type repoSHA struct {
|
||||
repoID int64
|
||||
sha string
|
||||
}
|
||||
|
||||
repoCheckSummaryMap := make(map[repoSHA]types.CheckCountSummary)
|
||||
for repoID, commitSHAs := range repoCommitSHAs {
|
||||
commitCheckSummaryMap, err := c.checkStore.ResultSummary(ctx, repoID, commitSHAs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to fetch check summary for commits: %w", err)
|
||||
}
|
||||
|
||||
for commitSHA, checkSummary := range commitCheckSummaryMap {
|
||||
repoCheckSummaryMap[repoSHA{repoID: repoID, sha: commitSHA.String()}] = checkSummary
|
||||
}
|
||||
}
|
||||
|
||||
// backfill the list with check count summary
|
||||
|
||||
for _, entry := range list {
|
||||
entry.PullRequest.CheckSummary =
|
||||
ptr.Of(repoCheckSummaryMap[repoSHA{repoID: entry.Repository.ID, sha: entry.PullRequest.SourceSHA}])
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackfillRules collects the rule metadata for the provided list of pull requests.
|
||||
func (c *ListService) BackfillRules(
|
||||
ctx context.Context,
|
||||
list []types.PullReqRepo,
|
||||
) error {
|
||||
// prepare list of branch names per repository
|
||||
|
||||
repoBranchNames := make(map[int64][]string)
|
||||
repoDefaultBranch := make(map[int64]string)
|
||||
for _, entry := range list {
|
||||
repoID := entry.Repository.ID
|
||||
branchNames := repoBranchNames[repoID]
|
||||
repoBranchNames[repoID] = append(branchNames, entry.PullRequest.TargetBranch)
|
||||
repoDefaultBranch[repoID] = entry.Repository.DefaultBranch
|
||||
}
|
||||
|
||||
// fetch checks for every repository
|
||||
|
||||
type repoBranchName struct {
|
||||
repoID int64
|
||||
branchName string
|
||||
}
|
||||
|
||||
repoBranchNameMap := make(map[repoBranchName][]types.RuleInfo)
|
||||
for repoID, branchNames := range repoBranchNames {
|
||||
repoProtection, err := c.protectionManager.ForRepository(ctx, repoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to fetch protection rules for repository: %w", err)
|
||||
}
|
||||
|
||||
for _, branchName := range branchNames {
|
||||
branchRuleInfos, err := protection.GetRuleInfos(
|
||||
repoProtection,
|
||||
repoDefaultBranch[repoID],
|
||||
branchName,
|
||||
protection.RuleInfoFilterStatusActive,
|
||||
protection.RuleInfoFilterTypeBranch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to get rule infos for branch %s: %w", branchName, err)
|
||||
}
|
||||
|
||||
repoBranchNameMap[repoBranchName{repoID: repoID, branchName: branchName}] = branchRuleInfos
|
||||
}
|
||||
}
|
||||
|
||||
// backfill the list with check count summary
|
||||
|
||||
for _, entry := range list {
|
||||
key := repoBranchName{repoID: entry.Repository.ID, branchName: entry.PullRequest.TargetBranch}
|
||||
entry.PullRequest.Rules = repoBranchNameMap[key]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ListService) BackfillMetadata(
|
||||
ctx context.Context,
|
||||
list []types.PullReqRepo,
|
||||
options types.PullReqMetadataOptions,
|
||||
) error {
|
||||
if options.IsAllFalse() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if options.IncludeChecks {
|
||||
if err := c.BackfillChecks(ctx, list); err != nil {
|
||||
return fmt.Errorf("failed to backfill checks")
|
||||
}
|
||||
}
|
||||
|
||||
if options.IncludeRules {
|
||||
if err := c.BackfillRules(ctx, list); err != nil {
|
||||
return fmt.Errorf("failed to backfill rules")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ListService) BackfillMetadataForRepo(
|
||||
ctx context.Context,
|
||||
repo *types.Repository,
|
||||
list []*types.PullReq,
|
||||
options types.PullReqMetadataOptions,
|
||||
) error {
|
||||
if options.IsAllFalse() {
|
||||
return nil
|
||||
}
|
||||
|
||||
listPullReqRepo := make([]types.PullReqRepo, len(list))
|
||||
for i, pr := range list {
|
||||
listPullReqRepo[i] = types.PullReqRepo{
|
||||
PullRequest: pr,
|
||||
Repository: repo,
|
||||
}
|
||||
}
|
||||
|
||||
if options.IncludeChecks {
|
||||
if err := c.BackfillChecks(ctx, listPullReqRepo); err != nil {
|
||||
return fmt.Errorf("failed to backfill checks")
|
||||
}
|
||||
}
|
||||
|
||||
if options.IncludeRules {
|
||||
if err := c.BackfillRules(ctx, listPullReqRepo); err != nil {
|
||||
return fmt.Errorf("failed to backfill rules")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ListService) BackfillMetadataForPullReq(
|
||||
ctx context.Context,
|
||||
repo *types.Repository,
|
||||
pr *types.PullReq,
|
||||
options types.PullReqMetadataOptions,
|
||||
) error {
|
||||
if options.IsAllFalse() {
|
||||
return nil
|
||||
}
|
||||
|
||||
list := []types.PullReqRepo{{
|
||||
PullRequest: pr,
|
||||
Repository: repo,
|
||||
}}
|
||||
|
||||
if options.IncludeChecks {
|
||||
if err := c.BackfillChecks(ctx, list); err != nil {
|
||||
return fmt.Errorf("failed to backfill checks")
|
||||
}
|
||||
}
|
||||
|
||||
if options.IncludeRules {
|
||||
if err := c.BackfillRules(ctx, list); err != nil {
|
||||
return fmt.Errorf("failed to backfill rules")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
pullreqevents "github.com/harness/gitness/app/events/pullreq"
|
||||
"github.com/harness/gitness/app/services/codecomments"
|
||||
"github.com/harness/gitness/app/services/label"
|
||||
"github.com/harness/gitness/app/services/protection"
|
||||
"github.com/harness/gitness/app/sse"
|
||||
"github.com/harness/gitness/app/store"
|
||||
"github.com/harness/gitness/app/url"
|
||||
@ -85,7 +86,9 @@ func ProvideListService(
|
||||
repoStore store.RepoStore,
|
||||
repoGitInfoCache store.RepoGitInfoCache,
|
||||
pullreqStore store.PullReqStore,
|
||||
checkStore store.CheckStore,
|
||||
labelSvc *label.Service,
|
||||
protectionManager *protection.Manager,
|
||||
) *ListService {
|
||||
return NewListService(
|
||||
tx,
|
||||
@ -95,6 +98,8 @@ func ProvideListService(
|
||||
repoStore,
|
||||
repoGitInfoCache,
|
||||
pullreqStore,
|
||||
checkStore,
|
||||
labelSvc,
|
||||
protectionManager,
|
||||
)
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
|
||||
connectorStore := database.ProvideConnectorStore(db, secretStore)
|
||||
repoGitInfoView := database.ProvideRepoGitInfoView(db)
|
||||
repoGitInfoCache := cache.ProvideRepoGitInfoCache(repoGitInfoView)
|
||||
listService := pullreq.ProvideListService(transactor, gitInterface, authorizer, spaceStore, repoStore, repoGitInfoCache, pullReqStore, labelService)
|
||||
listService := pullreq.ProvideListService(transactor, gitInterface, authorizer, spaceStore, repoStore, repoGitInfoCache, pullReqStore, checkStore, labelService, protectionManager)
|
||||
exporterRepository, err := exporter.ProvideSpaceExporter(provider, gitInterface, repoStore, jobScheduler, executor, encrypter, streamer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -64,7 +64,9 @@ type PullReq struct {
|
||||
Merger *PrincipalInfo `json:"merger"`
|
||||
Stats PullReqStats `json:"stats"`
|
||||
|
||||
Labels []*LabelPullReqAssignmentInfo `json:"labels,omitempty"`
|
||||
Labels []*LabelPullReqAssignmentInfo `json:"labels,omitempty"`
|
||||
CheckSummary *CheckCountSummary `json:"check_summary,omitempty"`
|
||||
Rules []RuleInfo `json:"rules,omitempty"`
|
||||
}
|
||||
|
||||
func (pr *PullReq) UpdateMergeOutcome(method enum.MergeMethod, conflictFiles []string) {
|
||||
@ -167,12 +169,22 @@ type PullReqFilter struct {
|
||||
CreatedFilter
|
||||
UpdatedFilter
|
||||
EditedFilter
|
||||
PullReqMetadataOptions
|
||||
|
||||
// internal use only
|
||||
SpaceIDs []int64
|
||||
RepoIDBlacklist []int64
|
||||
}
|
||||
|
||||
type PullReqMetadataOptions struct {
|
||||
IncludeChecks bool `json:"include_checks"`
|
||||
IncludeRules bool `json:"include_rules"`
|
||||
}
|
||||
|
||||
func (options PullReqMetadataOptions) IsAllFalse() bool {
|
||||
return !options.IncludeChecks && !options.IncludeRules
|
||||
}
|
||||
|
||||
// PullReqReview holds pull request review.
|
||||
type PullReqReview struct {
|
||||
ID int64 `json:"id"`
|
||||
|
Loading…
Reference in New Issue
Block a user