prow/tide/tide.go
func filterPR(ghc githubClient, sp *subpool, pr *PullRequest) bool {
	log := sp.log.WithFields(pr.logFields())
	// Skip PRs that are known to be unmergeable.
	if pr.Mergeable == githubql.MergeableStateConflicting {
		log.Debug("filtering out PR as it is unmergeable")
		return true
	}
	// Filter out PRs with unsuccessful contexts unless the only unsuccessful
	// contexts are pending required prowjobs.
	contexts, err := headContexts(log, ghc, pr)
	if err != nil {
		log.WithError(err).Error("Getting head contexts.")
		return true
	}
	presubmitsHaveContext := func(context string) bool {
		for _, job := range sp.presubmits[int(pr.Number)] {
			if job.Context == context {
				return true
			}
		}
		return false
	}
	for _, ctx := range unsuccessfulContexts(contexts, sp.cc, log) {
		if ctx.State != githubql.StatusStatePending {
			log.WithField("context", ctx.Context).Debug("filtering out PR as unsuccessful context is not pending")
			return true
		}
		if !presubmitsHaveContext(string(ctx.Context)) {
			log.WithField("context", ctx.Context).Debug("filtering out PR as unsuccessful context is not Prow-controlled")
			return true
		}
	}

	return false
}
func filterPR(ghc githubClient, sp *subpool, pr *PullRequest) bool {
	log := sp.log.WithFields(pr.logFields())
	// Skip PRs that are known to be unmergeable.
	if pr.Mergeable == githubql.MergeableStateConflicting {
		log.Debug("filtering out PR as it is unmergeable")
		return true
	}
	// Filter out PRs with unsuccessful contexts unless the only unsuccessful
	// contexts are pending required prowjobs.
	contexts, err := headContexts(log, ghc, pr)
	if err != nil {
		log.WithError(err).Error("Getting head contexts.")
		return true
	}
	presubmitsHaveContext := func(context string) bool {
		for _, job := range sp.presubmits[int(pr.Number)] {
			if job.Context == context {
				return true
			}
		}
		return false
	}
	for _, ctx := range unsuccessfulContexts(contexts, sp.cc, log) {
		if ctx.State != githubql.StatusStatePending {
			log.WithField("context", ctx.Context).Debug("filtering out PR as unsuccessful context is not pending")
			return true
		}
		if !presubmitsHaveContext(string(ctx.Context)) {
			log.WithField("context", ctx.Context).Debug("filtering out PR as unsuccessful context is not Prow-controlled")
			return true
		}
	}

	return false
}
func filterPR ( ghc githubClient , sp * subpool , pr * PullRequest ) bool { log := sp . log . WithFields ( pr . logFields ( ) ) // Skip PRs that are known to be unmergeable. if pr . Mergeable == githubql . MergeableStateConflicting { log . Debug ( " " ) return true } // Filter out PRs with unsuccessful contexts unless the only unsuccessful // contexts are pending required prowjobs. contexts , err := headContexts ( log , ghc , pr ) if err != nil { log . WithError ( err ) . Error ( " " ) return true } presubmitsHaveContext := func ( context string ) bool { for _ , job := range sp . presubmits [ int ( pr . Number ) ] { if job . Context == context { return true } } return false } for _ , ctx := range unsuccessfulContexts ( contexts , sp . cc , log ) { if ctx . State != githubql . StatusStatePending { log . WithField ( " " , ctx . Context ) . Debug ( " " ) return true } if ! presubmitsHaveContext ( string ( ctx . Context ) ) { log . WithField ( " " , ctx . Context ) . Debug ( " " ) return true } } return false }
// filterPR indicates if a PR should be filtered out of the subpool.
// Specifically we filter out PRs that:
// - Have known merge conflicts.
// - Have failing or missing status contexts.
// - Have pending required status contexts that are not associated with a
//   ProwJob. (This ensures that the 'tide' context indicates that the pending
//   status is preventing merge. Required ProwJob statuses are allowed to be
//   'pending' because this prevents kicking PRs from the pool when Tide is
//   retesting them.)
filterPR indicates if a PR should be filtered out of the subpool . Specifically we filter out PRs that : - Have known merge conflicts . - Have failing or missing status contexts . - Have pending required status contexts that are not associated with a ProwJob . ( This ensures that the tide context indicates that the pending status is preventing merge . Required ProwJob statuses are allowed to be pending because this prevents kicking PRs from the pool when Tide is retesting them . )