prow/plugins/requiresig/requiresig.go
func handle(log *logrus.Entry, ghc githubClient, cp commentPruner, ie *github.IssueEvent, mentionRe *regexp.Regexp) error {
	// Ignore PRs, closed issues, and events that aren't new issues or sig label
	// changes.
	if !shouldReact(mentionRe, ie) {
		return nil
	}

	org := ie.Repo.Owner.Login
	repo := ie.Repo.Name
	number := ie.Issue.Number

	hasSigLabel := hasSigLabel(ie.Issue.Labels)
	hasNeedsSigLabel := github.HasLabel(labels.NeedsSig, ie.Issue.Labels)

	if hasSigLabel && hasNeedsSigLabel {
		if err := ghc.RemoveLabel(org, repo, number, labels.NeedsSig); err != nil {
			log.WithError(err).Errorf("Failed to remove %s label.", labels.NeedsSig)
		}
		botName, err := ghc.BotName()
		if err != nil {
			return fmt.Errorf("error getting bot name: %v", err)
		}
		cp.PruneComments(shouldPrune(log, botName))
	} else if !hasSigLabel && !hasNeedsSigLabel {
		if err := ghc.AddLabel(org, repo, number, labels.NeedsSig); err != nil {
			log.WithError(err).Errorf("Failed to add %s label.", labels.NeedsSig)
		}
		msg := plugins.FormatResponse(ie.Issue.User.Login, needsSIGMessage, needsSIGDetails)
		if err := ghc.CreateComment(org, repo, number, msg); err != nil {
			log.WithError(err).Error("Failed to create comment.")
		}
	}
	return nil
}
func handle(log *logrus.Entry, ghc githubClient, cp commentPruner, ie *github.IssueEvent, mentionRe *regexp.Regexp) error {
	// Ignore PRs, closed issues, and events that aren't new issues or sig label
	// changes.
	if !shouldReact(mentionRe, ie) {
		return nil
	}

	org := ie.Repo.Owner.Login
	repo := ie.Repo.Name
	number := ie.Issue.Number

	hasSigLabel := hasSigLabel(ie.Issue.Labels)
	hasNeedsSigLabel := github.HasLabel(labels.NeedsSig, ie.Issue.Labels)

	if hasSigLabel && hasNeedsSigLabel {
		if err := ghc.RemoveLabel(org, repo, number, labels.NeedsSig); err != nil {
			log.WithError(err).Errorf("Failed to remove %s label.", labels.NeedsSig)
		}
		botName, err := ghc.BotName()
		if err != nil {
			return fmt.Errorf("error getting bot name: %v", err)
		}
		cp.PruneComments(shouldPrune(log, botName))
	} else if !hasSigLabel && !hasNeedsSigLabel {
		if err := ghc.AddLabel(org, repo, number, labels.NeedsSig); err != nil {
			log.WithError(err).Errorf("Failed to add %s label.", labels.NeedsSig)
		}
		msg := plugins.FormatResponse(ie.Issue.User.Login, needsSIGMessage, needsSIGDetails)
		if err := ghc.CreateComment(org, repo, number, msg); err != nil {
			log.WithError(err).Error("Failed to create comment.")
		}
	}
	return nil
}
func handle ( log * logrus . Entry , ghc githubClient , cp commentPruner , ie * github . IssueEvent , mentionRe * regexp . Regexp ) error { // Ignore PRs, closed issues, and events that aren't new issues or sig label // changes. if ! shouldReact ( mentionRe , ie ) { return nil } org := ie . Repo . Owner . Login repo := ie . Repo . Name number := ie . Issue . Number hasSigLabel := hasSigLabel ( ie . Issue . Labels ) hasNeedsSigLabel := github . HasLabel ( labels . NeedsSig , ie . Issue . Labels ) if hasSigLabel && hasNeedsSigLabel { if err := ghc . RemoveLabel ( org , repo , number , labels . NeedsSig ) ; err != nil { log . WithError ( err ) . Errorf ( " " , labels . NeedsSig ) } botName , err := ghc . BotName ( ) if err != nil { return fmt . Errorf ( " " , err ) } cp . PruneComments ( shouldPrune ( log , botName ) ) } else if ! hasSigLabel && ! hasNeedsSigLabel { if err := ghc . AddLabel ( org , repo , number , labels . NeedsSig ) ; err != nil { log . WithError ( err ) . Errorf ( " " , labels . NeedsSig ) } msg := plugins . FormatResponse ( ie . Issue . User . Login , needsSIGMessage , needsSIGDetails ) if err := ghc . CreateComment ( org , repo , number , msg ) ; err != nil { log . WithError ( err ) . Error ( " " ) } } return nil }
// handle is the workhorse notifying issue owner to add a sig label if there is none
// The algorithm:
// (1) return if this is not an opened, labelled, or unlabelled event or if the issue is closed.
// (2) find if the issue has a sig label
// (3) find if the issue has a needs-sig label
// (4) if the issue has both the sig and needs-sig labels, remove the needs-sig label and delete the comment.
// (5) if the issue has none of the labels, add the needs-sig label and comment
// (6) if the issue has only the sig label, do nothing
// (7) if the issue has only the needs-sig label, do nothing
handle is the workhorse notifying issue owner to add a sig label if there is none The algorithm : ( 1 ) return if this is not an opened labelled or unlabelled event or if the issue is closed . ( 2 ) find if the issue has a sig label ( 3 ) find if the issue has a needs - sig label ( 4 ) if the issue has both the sig and needs - sig labels remove the needs - sig label and delete the comment . ( 5 ) if the issue has none of the labels add the needs - sig label and comment ( 6 ) if the issue has only the sig label do nothing ( 7 ) if the issue has only the needs - sig label do nothing