Skip to content

Commit

Permalink
fix: include release notes and assembled date in json output after cr…
Browse files Browse the repository at this point in the history
…eating a release (#410)

* fix: include release notes and assembled date in json output after creating a release

* chore: refactor to appease tests
  • Loading branch information
hnrkndrssn authored Sep 19, 2024
1 parent 8914578 commit 42f2db6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/cmd/release/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"sort"
"strings"
"time"

"github.com/OctopusDeploy/cli/pkg/apiclient"

Expand Down Expand Up @@ -288,12 +289,16 @@ func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error
}

if options.Response != nil {
printReleaseVersion := func(releaseVersion string, channel *channels.Channel) {
printReleaseVersion := func(releaseVersion string, assembled time.Time, releaseNotes string, channel *channels.Channel) {
switch outputFormat {
case constants.OutputFormatBasic:
cmd.Printf("%s\n", releaseVersion)
case constants.OutputFormatJson:
v := &list.ReleaseViewModel{Version: releaseVersion}
v := &list.ReleaseViewModel{
Version: releaseVersion,
Assembled: assembled,
ReleaseNotes: releaseNotes,
}
if channel != nil {
v.Channel = channel.Name
}
Expand All @@ -317,14 +322,14 @@ func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error
newlyCreatedRelease, lookupErr := octopus.Releases.GetByID(options.Response.ReleaseID)
if lookupErr != nil {
cmd.PrintErrf("Warning: cannot fetch release details: %v\n", lookupErr)
printReleaseVersion(options.Response.ReleaseVersion, nil)
printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, nil)
} else {
releaseChan, lookupErr := octopus.Channels.GetByID(newlyCreatedRelease.ChannelID)
if lookupErr != nil {
cmd.PrintErrf("Warning: cannot fetch release channel details: %v\n", lookupErr)
printReleaseVersion(options.Response.ReleaseVersion, nil)
printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, nil)
} else {
printReleaseVersion(options.Response.ReleaseVersion, releaseChan)
printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, releaseChan)
}
}

Expand Down

0 comments on commit 42f2db6

Please sign in to comment.