Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Update JIRA issues from matching GitHub issues #4

Merged
merged 1 commit into from
Jul 20, 2017
Merged

Update JIRA issues from matching GitHub issues #4

merged 1 commit into from
Jul 20, 2017

Conversation

MorganEPatch
Copy link
Contributor

This PR builds on #2, and is thus blocked on it.

This PR adds the updateIssue() function, which updates a given JIRA issue from a given GitHub issue's title and description and the project passed in the config. It also sets the custom fields forthe GitHub labels and the time the tool ran. It only updates the fields which have been changed, or returns without doing anything if none of them have changed.

The function does not update the Reporter, Assignees, Issue Type, or Priority. These may be set in a future change. This function also does not update the issue status; this requires walking through the workflow using transitions, and is a much later planned feature.

fields.Description = *ghIssue.Body
}

key := fmt.Sprintf("customfield_%s", ghStatusFieldID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should create a constant for the customFieldTemplateString = "customefield_%s" to avoid errors going forward since this is used to heavily.

log.Errorf("Error updating JIRA issue %s: %s", jIssue.Key, err)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
log.Debugf("Error body: %s", body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more descriptive error please, e.g. error reading body from jira update issue request

cmd/root.go Outdated
return nil
}

func updateIssue(ghIssue github.Issue, jIssue jira.Issue, client jira.Client) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions have tons of gotcha's and check lots of different fields. How are you going to test this to make sure you are catching all the cases and correctly identifying changed issues? Please make a func called e.g. areIssuesSame or compareIssue etc that returns a bool if the issues are the same and write a test for it. This function can be easily tested. Now, update updateIssue to only update an issue if the previous function returns false. Also, this way, updateIssue can indiscriminately set all members of the fields struct and send of the request. it isolates concerns

This commit adds issue updating. It can update the Summary,
Description, GitHub labels, GitHub status, and GitHub
reporter, as well as changing the last update time.
@MorganEPatch MorganEPatch merged commit 41fa056 into coreos:master Jul 20, 2017
macpijan pushed a commit to 3mdeb/issue-sync that referenced this pull request Sep 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants