Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generator] breaking change items will have empty array if there is not any #14556

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tools/generator/autorest/model/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c Changelog) ToCompactMarkdown() string {
// GetBreakingChangeItems returns an array of the breaking change items
func (c Changelog) GetBreakingChangeItems() []string {
if c.Modified == nil {
return nil
return []string{}
}
return getBreakingChanges(c.Modified.BreakingChanges)
}
Expand Down Expand Up @@ -155,12 +155,11 @@ func getNewContents(c *delta.Content) []string {
}

func getBreakingChanges(b *report.BreakingChanges) []string {
items := make([]string, 0)
if b == nil || b.IsEmpty() {
return nil
return items
}

var items []string

// get signature changes
items = append(items, getSignatureChangeItems(b)...)

Expand Down
3 changes: 2 additions & 1 deletion tools/generator/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (ctx generateContext) generate(input *pipeline.GenerateInput) (*pipeline.Ge
log.Printf("Getting package result for package '%s'", p.PackageName)
content := p.Changelog.ToCompactMarkdown()
breaking := p.Changelog.HasBreakingChanges()
breakingChangeItems := p.Changelog.GetBreakingChangeItems()
set.add(pipeline.PackageResult{
Version: version.Number,
PackageName: getPackageIdentifier(p.PackageName),
Expand All @@ -217,7 +218,7 @@ func (ctx generateContext) generate(input *pipeline.GenerateInput) (*pipeline.Ge
Changelog: &pipeline.Changelog{
Content: &content,
HasBreakingChange: &breaking,
BreakingChangeItems: p.Changelog.GetBreakingChangeItems(),
BreakingChangeItems: &breakingChangeItems,
},
})
}
Expand Down
6 changes: 3 additions & 3 deletions tools/generator/pipeline/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ type PackageResult struct {

// Changelog ...
type Changelog struct {
Content *string `json:"content,omitempty"`
HasBreakingChange *bool `json:"hasBreakingChange,omitempty"`
BreakingChangeItems []string `json:"breakingChangeItems,omitempty"`
Content *string `json:"content,omitempty"`
HasBreakingChange *bool `json:"hasBreakingChange,omitempty"`
BreakingChangeItems *[]string `json:"breakingChangeItems,omitempty"`
}

// InstallInstructionScriptOutput ...
Expand Down