// UpdateIssue compares each field of a GitHub issue to a JIRA issue; if any of them
// differ, the differing fields of the JIRA issue are updated to match the GitHub
// issue.
UpdateIssue compares each field of a GitHub issue to a JIRA issue; if any of them
differ, the differing fields of the JIRA issue are updated to match the GitHub
issue.
// UpdateIssue compares each field of a GitHub issue to a JIRA issue ; if any of them // differ the differing fields of the JIRA issue are updated to match the GitHub // issue .
func UpdateIssue(config cfg.Config, ghIssue github.Issue, jIssue jira.Issue, ghClient clients.GitHubClient, jClient clients.JIRAClient) error {
	log := config.GetLogger()
	log.Debugf("Updating JIRA %s with GitHub #%d", jIssue.Key, *ghIssue.Number)
	var issue jira.Issue
	if DidIssueChange(config, ghIssue, jIssue) {
		fields := jira.IssueFields{}
		fields.Unknowns = map[string]interface{}{}
		fields.Summary = ghIssue.GetTitle()
		fields.Description = ghIssue.GetBody()
		fields.Unknowns[config.GetFieldKey(cfg.GitHubStatus)] = ghIssue.GetState()
		fields.Unknowns[config.GetFieldKey(cfg.GitHubReporter)] = ghIssue.User.GetLogin()
		labels := make([]string, len(ghIssue.Labels))
		for i, l := range ghIssue.Labels {
			labels[i] = l.GetName()
		}
		fields.Unknowns[config.GetFieldKey(cfg.GitHubLabels)] = strings.Join(labels, ",")
		fields.Unknowns[config.GetFieldKey(cfg.LastISUpdate)] = time.Now().Format(dateFormat)
		fields.Type = jIssue.Fields.Type
		issue = jira.Issue{
			Fields: &fields,
			Key:    jIssue.Key,
			ID:     jIssue.ID,
		}
		var err error
		issue, err = jClient.UpdateIssue(issue)
		if err != nil {
			return err
		}
		log.Debugf("Successfully updated JIRA issue %s!", jIssue.Key)
	} else {
		log.Debugf("JIRA issue %s is already up to date!", jIssue.Key)
	}
	issue, err := jClient.GetIssue(jIssue.Key)
	if err != nil {
		log.Debugf("Failed to retrieve JIRA issue %s!", jIssue.Key)
		return err
	}
	if err := CompareComments(config, ghIssue, issue, ghClient, jClient); err != nil {
		return err
	}
	return nil
}
func UpdateIssue ( config cfg . Config , ghIssue github . Issue , jIssue jira . Issue , ghClient clients . GitHubClient , jClient clients . JIRAClient ) error { log := config . GetLogger ( ) log . Debugf ( " " , jIssue . Key , * ghIssue . Number ) var issue jira . Issue if DidIssueChange ( config , ghIssue , jIssue ) { fields := jira . IssueFields { } fields . Unknowns = map [ string ] interface { } { } fields . Summary = ghIssue . GetTitle ( ) fields . Description = ghIssue . GetBody ( ) fields . Unknowns [ config . GetFieldKey ( cfg . GitHubStatus ) ] = ghIssue . GetState ( ) fields . Unknowns [ config . GetFieldKey ( cfg . GitHubReporter ) ] = ghIssue . User . GetLogin ( ) labels := make ( [ ] string , len ( ghIssue . Labels ) ) for i , l := range ghIssue . Labels { labels [ i ] = l . GetName ( ) } fields . Unknowns [ config . GetFieldKey ( cfg . GitHubLabels ) ] = strings . Join ( labels , " " ) fields . Unknowns [ config . GetFieldKey ( cfg . LastISUpdate ) ] = time . Now ( ) . Format ( dateFormat ) fields . Type = jIssue . Fields . Type issue = jira . Issue { Fields : & fields , Key : jIssue . Key , ID : jIssue . ID , } var err error issue , err = jClient . UpdateIssue ( issue ) if err != nil { return err } log . Debugf ( " " , jIssue . Key ) } else { log . Debugf ( " " , jIssue . Key ) } issue , err := jClient . GetIssue ( jIssue . Key ) if err != nil { log . Debugf ( " " , jIssue . Key ) return err } if err := CompareComments ( config , ghIssue , issue , ghClient , jClient ) ; err != nil { return err } return nil }
UpdateIssue compares each field of a GitHub issue to a JIRA issue; if any of them
differ, the differing fields of the JIRA issue are updated to match the GitHub
issue.
UpdateIssue compares each field of a GitHub issue to a JIRA issue ; if any of them differ the differing fields of the JIRA issue are updated to match the GitHub issue .