Skip to content

Commit

Permalink
Merge pull request #103 from AlexNPavel/better-backport-comment
Browse files Browse the repository at this point in the history
server: improve comment for backport
  • Loading branch information
openshift-merge-bot[bot] committed Jul 10, 2024
2 parents 608a3c0 + 88909de commit b07073a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/jira-lifecycle-plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,7 @@ func handleBackport(e event, gc githubClient, jc jiraclient.Client, repoOptions
if len(branchesMissingDependents) != 0 {
return comment(fmt.Sprintf("Missing required branches for backport chain: %v", missingDependencies.UnsortedList()))
}
createdIssuesMessageLines := []string{}
for _, refIssue := range e.issues {
if !refIssue.IsBug {
continue
Expand All @@ -2049,6 +2050,7 @@ func handleBackport(e event, gc githubClient, jc jiraclient.Client, repoOptions
var newLabels []string
for key, branch := range createdIssues {
newLabels = append(newLabels, fmt.Sprintf("jlp-%s:%s", branch, key))
createdIssuesMessageLines = append(createdIssuesMessageLines, insertLinksIntoLine(fmt.Sprintf("- %s for branch %s", key, branch), []string{key}, jc.JiraURL()))
}
// sorting the labels isn't necessary for production but helps with tests
sort.Strings(newLabels)
Expand All @@ -2058,7 +2060,10 @@ func handleBackport(e event, gc githubClient, jc jiraclient.Client, repoOptions
return comment(fmt.Sprintf("Failed to add label to issue %s: %v", issue.Key, err))
}
}
return comment(fmt.Sprintf("All backport jira issues created. Queuing cherrypicks to the requested branches to be created after this PR merges:\n%s", cherrypickBranches))
// make message deterministic for tests
sort.Strings(createdIssuesMessageLines)
createdIssuesMessage := strings.Join(createdIssuesMessageLines, "\n")
return comment(fmt.Sprintf("The following backport issues have been created:\n%s\n\nQueuing cherrypicks to the requested branches to be created after this PR merges:%s", createdIssuesMessage, cherrypickBranches))
}

// createLinkedJiras recursively creates all descendants of the provided parent issue based on the child branches map
Expand Down
7 changes: 6 additions & 1 deletion cmd/jira-lifecycle-plugin/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2988,8 +2988,13 @@ Instructions for interacting with me using PR comments are available [here](http
"v4": {TargetVersion: &v4Str, DependentBugTargetVersions: &[]string{v5Str}},
"v5": {TargetVersion: &v5Str, DependentBugTargetVersions: nil},
},
expectedComment: `org/repo#1:@user: All backport jira issues created. Queuing cherrypicks to the requested branches to be created after this PR merges:
expectedComment: `org/repo#1:@user: The following backport issues have been created:
- [OCPBUGS-124](https://my-jira.com/browse/OCPBUGS-124) for branch v4
- [OCPBUGS-125](https://my-jira.com/browse/OCPBUGS-125) for branch v3
- [OCPBUGS-126](https://my-jira.com/browse/OCPBUGS-126) for branch v2
- [OCPBUGS-127](https://my-jira.com/browse/OCPBUGS-127) for branch v1
Queuing cherrypicks to the requested branches to be created after this PR merges:
/cherrypick v1
/cherrypick v2
/cherrypick v3
Expand Down

0 comments on commit b07073a

Please sign in to comment.