Skip to content

Commit

Permalink
Avoid linking the same issues (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Owsiany <[email protected]>
  • Loading branch information
mtodor and porridge authored Nov 14, 2024
1 parent 696df52 commit 5b8bdf4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ func (j junit2jira) linkIssues(issues []*jira.Issue) error {
var result error
for x, issue := range issues {
for y := 0; y < x; y++ {
// Skip cases where we have the same inward and outward issue.
// Jira does not allow linking a ticket to itself.
if issue.Key == issues[y].Key {
continue
}

_, err := j.jiraClient.Issue.AddLink(&jira.IssueLink{
Type: jira.IssueLinkType{Name: linkType},
OutwardIssue: &jira.Issue{Key: issue.Key},
Expand Down

0 comments on commit 5b8bdf4

Please sign in to comment.