robots/issue-creator/creator/creator.go
func (c *IssueCreator) sync(issue Issue) bool {
	// First look for existing issues with this ID.
	id := issue.ID()
	var closedIssues []*github.Issue
	for _, i := range c.allIssues {
		if strings.Contains(*i.Body, id) {
			switch *i.State {
			case "open":
				//if an open issue is found with the ID then the issue is already synced
				return false
			case "closed":
				closedIssues = append(closedIssues, i)
			default:
				glog.Errorf("Unrecognized issue state '%s' for issue #%d. Ignoring this issue.\n", *i.State, *i.Number)
			}
		}
	}
	// No open issues exist for the ID.
	body := issue.Body(closedIssues)
	if body == "" {
		// Issue indicated that it should not be synced.
		glog.Infof("Issue aborted sync by providing \"\" (empty) body. ID: %s.", id)
		return false
	}
	if !strings.Contains(body, id) {
		glog.Fatalf("Programmer error: The following body text does not contain id '%s'.\n%s\n", id, body)
	}

	title := issue.Title()
	owners := issue.Owners()
	if c.Collaborators != nil {
		var removedOwners []string
		owners, removedOwners = setIntersect(owners, c.Collaborators)
		if len(removedOwners) > 0 {
			glog.Errorf("Filtered the following invalid assignees from issue %q: %q.", title, removedOwners)
		}
	}

	labels := issue.Labels()
	if prio, ok := issue.Priority(); ok {
		labels = append(labels, "priority/"+prio)
	}
	if c.validLabels != nil {
		var removedLabels []string
		labels, removedLabels = setIntersect(labels, c.validLabels)
		if len(removedLabels) > 0 {
			glog.Errorf("Filtered the following invalid labels from issue %q: %q.", title, removedLabels)
		}
	}

	glog.Infof("Create Issue: %q Assigned to: %q\n", title, owners)
	if c.dryRun {
		return true
	}

	created, err := c.client.CreateIssue(c.org, c.project, title, body, labels, owners)
	if err != nil {
		glog.Errorf("Failed to create a new github issue for issue ID '%s'.\n", id)
		return false
	}
	c.allIssues[*created.Number] = created
	return true
}
func (c *IssueCreator) sync(issue Issue) bool {
	// First look for existing issues with this ID.
	id := issue.ID()
	var closedIssues []*github.Issue
	for _, i := range c.allIssues {
		if strings.Contains(*i.Body, id) {
			switch *i.State {
			case "open":
				//if an open issue is found with the ID then the issue is already synced
				return false
			case "closed":
				closedIssues = append(closedIssues, i)
			default:
				glog.Errorf("Unrecognized issue state '%s' for issue #%d. Ignoring this issue.\n", *i.State, *i.Number)
			}
		}
	}
	// No open issues exist for the ID.
	body := issue.Body(closedIssues)
	if body == "" {
		// Issue indicated that it should not be synced.
		glog.Infof("Issue aborted sync by providing \"\" (empty) body. ID: %s.", id)
		return false
	}
	if !strings.Contains(body, id) {
		glog.Fatalf("Programmer error: The following body text does not contain id '%s'.\n%s\n", id, body)
	}

	title := issue.Title()
	owners := issue.Owners()
	if c.Collaborators != nil {
		var removedOwners []string
		owners, removedOwners = setIntersect(owners, c.Collaborators)
		if len(removedOwners) > 0 {
			glog.Errorf("Filtered the following invalid assignees from issue %q: %q.", title, removedOwners)
		}
	}

	labels := issue.Labels()
	if prio, ok := issue.Priority(); ok {
		labels = append(labels, "priority/"+prio)
	}
	if c.validLabels != nil {
		var removedLabels []string
		labels, removedLabels = setIntersect(labels, c.validLabels)
		if len(removedLabels) > 0 {
			glog.Errorf("Filtered the following invalid labels from issue %q: %q.", title, removedLabels)
		}
	}

	glog.Infof("Create Issue: %q Assigned to: %q\n", title, owners)
	if c.dryRun {
		return true
	}

	created, err := c.client.CreateIssue(c.org, c.project, title, body, labels, owners)
	if err != nil {
		glog.Errorf("Failed to create a new github issue for issue ID '%s'.\n", id)
		return false
	}
	c.allIssues[*created.Number] = created
	return true
}
func ( c * IssueCreator ) sync ( issue Issue ) bool { // First look for existing issues with this ID. id := issue . ID ( ) var closedIssues [ ] * github . Issue for _ , i := range c . allIssues { if strings . Contains ( * i . Body , id ) { switch * i . State { case " " : //if an open issue is found with the ID then the issue is already synced return false case " " : closedIssues = append ( closedIssues , i ) default : glog . Errorf ( " \n " , * i . State , * i . Number ) } } } // No open issues exist for the ID. body := issue . Body ( closedIssues ) if body == " " { // Issue indicated that it should not be synced. glog . Infof ( " \" \" " , id ) return false } if ! strings . Contains ( body , id ) { glog . Fatalf ( " \n \n " , id , body ) } title := issue . Title ( ) owners := issue . Owners ( ) if c . Collaborators != nil { var removedOwners [ ] string owners , removedOwners = setIntersect ( owners , c . Collaborators ) if len ( removedOwners ) > 0 { glog . Errorf ( " " , title , removedOwners ) } } labels := issue . Labels ( ) if prio , ok := issue . Priority ( ) ; ok { labels = append ( labels , " " + prio ) } if c . validLabels != nil { var removedLabels [ ] string labels , removedLabels = setIntersect ( labels , c . validLabels ) if len ( removedLabels ) > 0 { glog . Errorf ( " " , title , removedLabels ) } } glog . Infof ( " \n " , title , owners ) if c . dryRun { return true } created , err := c . client . CreateIssue ( c . org , c . project , title , body , labels , owners ) if err != nil { glog . Errorf ( " \n " , id ) return false } c . allIssues [ * created . Number ] = created return true }
// sync checks to see if an issue is already on github and tries to create a new issue for it if it is not.
// True is returned iff a new issue is created.
sync checks to see if an issue is already on github and tries to create a new issue for it if it is not . True is returned iff a new issue is created .