prow/plugins/approve/approve.go
func addApprovers(approversHandler *approvers.Approvers, approveComments []*comment, author string, reviewActsAsApprove bool) {
	for _, c := range approveComments {
		if c.Author == "" {
			continue
		}

		if reviewActsAsApprove && c.ReviewState == github.ReviewStateApproved {
			approversHandler.AddApprover(
				c.Author,
				c.HTMLURL,
				false,
			)
		}
		if reviewActsAsApprove && c.ReviewState == github.ReviewStateChangesRequested {
			approversHandler.RemoveApprover(c.Author)
		}

		for _, match := range commandRegex.FindAllStringSubmatch(c.Body, -1) {
			name := strings.ToUpper(match[1])
			if name != approveCommand && name != lgtmCommand {
				continue
			}
			args := strings.ToLower(strings.TrimSpace(match[2]))
			if strings.Contains(args, cancelArgument) {
				approversHandler.RemoveApprover(c.Author)
				continue
			}

			if c.Author == author {
				approversHandler.AddAuthorSelfApprover(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			}

			if name == approveCommand {
				approversHandler.AddApprover(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			} else {
				approversHandler.AddLGTMer(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			}

		}
	}
}
func addApprovers(approversHandler *approvers.Approvers, approveComments []*comment, author string, reviewActsAsApprove bool) {
	for _, c := range approveComments {
		if c.Author == "" {
			continue
		}

		if reviewActsAsApprove && c.ReviewState == github.ReviewStateApproved {
			approversHandler.AddApprover(
				c.Author,
				c.HTMLURL,
				false,
			)
		}
		if reviewActsAsApprove && c.ReviewState == github.ReviewStateChangesRequested {
			approversHandler.RemoveApprover(c.Author)
		}

		for _, match := range commandRegex.FindAllStringSubmatch(c.Body, -1) {
			name := strings.ToUpper(match[1])
			if name != approveCommand && name != lgtmCommand {
				continue
			}
			args := strings.ToLower(strings.TrimSpace(match[2]))
			if strings.Contains(args, cancelArgument) {
				approversHandler.RemoveApprover(c.Author)
				continue
			}

			if c.Author == author {
				approversHandler.AddAuthorSelfApprover(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			}

			if name == approveCommand {
				approversHandler.AddApprover(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			} else {
				approversHandler.AddLGTMer(
					c.Author,
					c.HTMLURL,
					args == noIssueArgument,
				)
			}

		}
	}
}
func addApprovers ( approversHandler * approvers . Approvers , approveComments [ ] * comment , author string , reviewActsAsApprove bool ) { for _ , c := range approveComments { if c . Author == " " { continue } if reviewActsAsApprove && c . ReviewState == github . ReviewStateApproved { approversHandler . AddApprover ( c . Author , c . HTMLURL , false , ) } if reviewActsAsApprove && c . ReviewState == github . ReviewStateChangesRequested { approversHandler . RemoveApprover ( c . Author ) } for _ , match := range commandRegex . FindAllStringSubmatch ( c . Body , - 1 ) { name := strings . ToUpper ( match [ 1 ] ) if name != approveCommand && name != lgtmCommand { continue } args := strings . ToLower ( strings . TrimSpace ( match [ 2 ] ) ) if strings . Contains ( args , cancelArgument ) { approversHandler . RemoveApprover ( c . Author ) continue } if c . Author == author { approversHandler . AddAuthorSelfApprover ( c . Author , c . HTMLURL , args == noIssueArgument , ) } if name == approveCommand { approversHandler . AddApprover ( c . Author , c . HTMLURL , args == noIssueArgument , ) } else { approversHandler . AddLGTMer ( c . Author , c . HTMLURL , args == noIssueArgument , ) } } } }
// addApprovers iterates through the list of comments on a PR
// and identifies all of the people that have said /approve and adds
// them to the Approvers.  The function uses the latest approve or cancel comment
// to determine the Users intention. A review in requested changes state is
// considered a cancel.
addApprovers iterates through the list of comments on a PR and identifies all of the people that have said / approve and adds them to the Approvers . The function uses the latest approve or cancel comment to determine the Users intention . A review in requested changes state is considered a cancel .