prow/plugins/hold/hold.go
func handle(gc githubClient, log *logrus.Entry, e *github.GenericCommentEvent, f hasLabelFunc) error {
	if e.Action != github.GenericCommentActionCreated {
		return nil
	}
	needsLabel := false
	if labelRe.MatchString(e.Body) {
		needsLabel = true
	} else if labelCancelRe.MatchString(e.Body) {
		needsLabel = false
	} else {
		return nil
	}

	org := e.Repo.Owner.Login
	repo := e.Repo.Name
	issueLabels, err := gc.GetIssueLabels(org, repo, e.Number)
	if err != nil {
		return fmt.Errorf("failed to get the labels on %s/%s#%d: %v", org, repo, e.Number, err)
	}

	hasLabel := f(labels.Hold, issueLabels)
	if hasLabel && !needsLabel {
		log.Infof("Removing %q Label for %s/%s#%d", labels.Hold, org, repo, e.Number)
		return gc.RemoveLabel(org, repo, e.Number, labels.Hold)
	} else if !hasLabel && needsLabel {
		log.Infof("Adding %q Label for %s/%s#%d", labels.Hold, org, repo, e.Number)
		return gc.AddLabel(org, repo, e.Number, labels.Hold)
	}
	return nil
}
func handle(gc githubClient, log *logrus.Entry, e *github.GenericCommentEvent, f hasLabelFunc) error {
	if e.Action != github.GenericCommentActionCreated {
		return nil
	}
	needsLabel := false
	if labelRe.MatchString(e.Body) {
		needsLabel = true
	} else if labelCancelRe.MatchString(e.Body) {
		needsLabel = false
	} else {
		return nil
	}

	org := e.Repo.Owner.Login
	repo := e.Repo.Name
	issueLabels, err := gc.GetIssueLabels(org, repo, e.Number)
	if err != nil {
		return fmt.Errorf("failed to get the labels on %s/%s#%d: %v", org, repo, e.Number, err)
	}

	hasLabel := f(labels.Hold, issueLabels)
	if hasLabel && !needsLabel {
		log.Infof("Removing %q Label for %s/%s#%d", labels.Hold, org, repo, e.Number)
		return gc.RemoveLabel(org, repo, e.Number, labels.Hold)
	} else if !hasLabel && needsLabel {
		log.Infof("Adding %q Label for %s/%s#%d", labels.Hold, org, repo, e.Number)
		return gc.AddLabel(org, repo, e.Number, labels.Hold)
	}
	return nil
}
// handle drives the pull request to the desired state. If any user adds
// a /hold directive, we want to add a label if one does not already exist.
// If they add /hold cancel, we want to remove the label if it exists.