func handle(gc gitHubClient, log *logrus.Entry, se github.StatusEvent) error {

	log.Info("Status event is %s",se.State)
	if se.State == "" || se.Context == "" {
		return fmt.Errorf("invalid status event delivered with empty state/context")
	}

	if se.Context != conformanceContextName {
		// Not the CNCF CLA context, do not process this.
		return nil
	}

	if se.State == github.StatusPending {
		// do nothing and wait for state to be updated.
		return nil
	}

	org := se.Repo.Owner.Login
	repo := se.Repo.Name
	log.Info("%s/%s Searching for PRs matching the commit.", org,repo)
	// hunting for issues  feels like overkil for our use case
	// we only really want to check PR contents
	// We may have put on the wrong trousers
	var issues []github.Issue
	var err error
	for i := 0; i < maxRetries; i++ {
		issues, err = gc.FindIssues(fmt.Sprintf("%s repo:%s/%s type:pr state:open", se.SHA, org, repo), "", false)
		if err != nil {
			return fmt.Errorf("error searching for issues matching commit: %v", err)
		}
		if len(issues) > 0 {
			break
		}
		time.Sleep(10 * time.Second)
	}
	log.Infof("Found %d PRs matching commit.", len(issues))

	return nil
}
// 1. Check that the status event received from the webhook is for the CNCF-CLA.
// 2. Use the github search API to search for the PRs which match the commit hash corresponding to the status event.
// 3. For each issue that matches, check that the PR's HEAD commit hash against the commit hash for which the status
//    was received. This is because we only care about the status associated with the last (latest) commit in a PR.
// 4. Set the corresponding CLA label if needed.
1. Check that the status event received from the webhook is for the CNCF-CLA.
2. Use the github search API to search for the PRs which match the commit hash corresponding to the status event.
3. For each issue that matches, check that the PR's HEAD commit hash against the commit hash for which the status
was received. This is because we only care about the status associated with the last (latest) commit in a PR.
4. Set the corresponding CLA label if needed.
// 1 . Check that the status event received from the webhook is for the CNCF - CLA . // 2 . Use the github search API to search for the PRs which match the commit hash corresponding to the status event . // 3 . For each issue that matches check that the PR ' s HEAD commit hash against the commit hash for which the status // was received . This is because we only care about the status associated with the last ( latest ) commit in a PR . // 4 . Set the corresponding CLA label if needed .
func handle(gc gitHubClient, log *logrus.Entry, se github.StatusEvent) error {
	log.Info("Status event is %s",se.State)
	if se.State == "" || se.Context == "" {
		return fmt.Errorf("invalid status event delivered with empty state/context")
	}
	if se.Context != conformanceContextName {
		return nil
	}
	if se.State == github.StatusPending {
		return nil
	}
	org := se.Repo.Owner.Login
	repo := se.Repo.Name
	log.Info("%s/%s Searching for PRs matching the commit.", org,repo)
	var issues []github.Issue
	var err error
	for i := 0; i < maxRetries; i++ {
		issues, err = gc.FindIssues(fmt.Sprintf("%s repo:%s/%s type:pr state:open", se.SHA, org, repo), "", false)
		if err != nil {
			return fmt.Errorf("error searching for issues matching commit: %v", err)
		}
		if len(issues) > 0 {
			break
		}
		time.Sleep(10 * time.Second)
	}
	log.Infof("Found %d PRs matching commit.", len(issues))
	return nil
}
func handle ( gc gitHubClient , log * logrus . Entry , se github . StatusEvent ) error { log . Info ( " " , se . State ) if se . State == " " || se . Context == " " { return fmt . Errorf ( " " ) } if se . Context != conformanceContextName { return nil } if se . State == github . StatusPending { return nil } org := se . Repo . Owner . Login repo := se . Repo . Name log . Info ( " " , org , repo ) var issues [ ] github . Issue var err error for i := 0 ; i < maxRetries ; i ++ { issues , err = gc . FindIssues ( fmt . Sprintf ( " " , se . SHA , org , repo ) , " " , false ) if err != nil { return fmt . Errorf ( " " , err ) } if len ( issues ) > 0 { break } time . Sleep ( 10 * time . Second ) } log . Infof ( " " , len ( issues ) ) return nil }
1.
1 .
// Not the CNCF CLA context, do not process this. // do nothing and wait for state to be updated. // hunting for issues  feels like overkil for our use case // we only really want to check PR contents // We may have put on the wrong trousers