Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
[core] count reviews based community reviewer and c3i team
Browse files Browse the repository at this point in the history
all approvals are still displayed and it takes one approval from anyone to have it displayed.

start of #6
  • Loading branch information
prince-chrismc committed Jan 17, 2021
1 parent 7cd48bf commit 40d3ef9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pending_review/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type PullRequestStatus struct {
LastCommitSHA string
LastCommitAt time.Time
Reviews int
AtLeastOneApproval bool
ValidApprovals int
IsMergeable bool
HeadCommitApprovals []string
HeadCommitBlockers []string
Expand Down Expand Up @@ -102,30 +102,36 @@ func (s *PullRequestService) GatherRelevantReviews(ctx context.Context, owner st

p.HeadCommitApprovals = removeUnique(p.HeadCommitApprovals, reviewerName)
case APPRVD:
p.AtLeastOneApproval = true
if onBranchHead {
p.HeadCommitApprovals = appendUnique(p.HeadCommitApprovals, reviewerName)
if isC3iTeam {
atleastOneTeamApproval = true
p.ValidApprovals = p.ValidApprovals + 1
}
}

switch reviewerName {
case "madebr", "SpaceIm", "ericLemanissier", "prince-chrismc", "Croydon", "intelligide", "theirix", "gocarlos":
p.ValidApprovals = p.ValidApprovals + 1
default:
}

p.HeadCommitBlockers = removeUnique(p.HeadCommitBlockers, reviewerName)
case DISMISSED:
p.HeadCommitBlockers = removeUnique(p.HeadCommitBlockers, reviewerName)
default:
}
}

p.IsMergeable = atleastOneTeamApproval && len(p.HeadCommitApprovals) >= 3 && len(p.HeadCommitBlockers) == 0
p.IsMergeable = atleastOneTeamApproval && p.ValidApprovals >= 3 && len(p.HeadCommitBlockers) == 0

if resp.NextPage == 0 {
break
}
opt.Page = resp.NextPage
}

if p.AtLeastOneApproval {
if len(p.HeadCommitApprovals) > 0 {
return p, resp, nil
}

Expand Down

0 comments on commit 40d3ef9

Please sign in to comment.