mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
githubPublishRelease: fix the link which points to changes between the last release and the new one (#4296)
This commit is contained in:
parent
f5c33d51bb
commit
d6e72995b0
@ -145,17 +145,18 @@ func getClosedIssuesText(ctx context.Context, publishedAt github.Timestamp, conf
|
||||
|
||||
func getReleaseDeltaText(config *githubPublishReleaseOptions, lastRelease *github.RepositoryRelease) string {
|
||||
releaseDeltaText := ""
|
||||
tagName := config.TagPrefix + config.Version
|
||||
|
||||
// add delta link to previous release
|
||||
releaseDeltaText += "\n**Changes**\n"
|
||||
releaseDeltaText += fmt.Sprintf(
|
||||
"[%v...%v](%v/%v/%v/compare/%v...%v)\n",
|
||||
lastRelease.GetTagName(),
|
||||
config.Version,
|
||||
tagName,
|
||||
config.ServerURL,
|
||||
config.Owner,
|
||||
config.Repository,
|
||||
lastRelease.GetTagName(), config.Version,
|
||||
lastRelease.GetTagName(), tagName,
|
||||
)
|
||||
|
||||
return releaseDeltaText
|
||||
|
@ -314,20 +314,36 @@ func TestGetClosedIssuesText(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetReleaseDeltaText(t *testing.T) {
|
||||
myGithubPublishReleaseOptions := githubPublishReleaseOptions{
|
||||
Owner: "TEST",
|
||||
Repository: "test",
|
||||
ServerURL: "https://github.com",
|
||||
Version: "1.1",
|
||||
}
|
||||
lastTag := "1.0"
|
||||
lastRelease := github.RepositoryRelease{
|
||||
TagName: &lastTag,
|
||||
}
|
||||
t.Run("test case without TagPrefix for new release", func(t *testing.T) {
|
||||
myGithubPublishReleaseOptions := githubPublishReleaseOptions{
|
||||
Owner: "TEST",
|
||||
Repository: "test",
|
||||
ServerURL: "https://github.com",
|
||||
Version: "1.1",
|
||||
}
|
||||
lastTag := "1.0"
|
||||
lastRelease := github.RepositoryRelease{
|
||||
TagName: &lastTag,
|
||||
}
|
||||
res := getReleaseDeltaText(&myGithubPublishReleaseOptions, &lastRelease)
|
||||
assert.Equal(t, "\n**Changes**\n[1.0...1.1](https://github.com/TEST/test/compare/1.0...1.1)\n", res)
|
||||
})
|
||||
|
||||
res := getReleaseDeltaText(&myGithubPublishReleaseOptions, &lastRelease)
|
||||
|
||||
assert.Equal(t, "\n**Changes**\n[1.0...1.1](https://github.com/TEST/test/compare/1.0...1.1)\n", res)
|
||||
t.Run("test case with TagPrefix for new release", func(t *testing.T) {
|
||||
myGithubPublishReleaseOptions := githubPublishReleaseOptions{
|
||||
Owner: "TEST",
|
||||
Repository: "test",
|
||||
ServerURL: "https://github.com",
|
||||
Version: "1.1",
|
||||
TagPrefix: "release/",
|
||||
}
|
||||
lastTag := "1.0"
|
||||
lastRelease := github.RepositoryRelease{
|
||||
TagName: &lastTag,
|
||||
}
|
||||
res := getReleaseDeltaText(&myGithubPublishReleaseOptions, &lastRelease)
|
||||
assert.Equal(t, "\n**Changes**\n[1.0...release/1.1](https://github.com/TEST/test/compare/1.0...release/1.1)\n", res)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUploadReleaseAsset(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user