Skip to content

Commit

Permalink
fix: Improve changelog formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpt-erikgeiser committed Jul 15, 2020
1 parent d2e9097 commit 4f94179
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions acceptance/testdata/rpm.changelog.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ ARG package
COPY ${package} /tmp/foo.rpm
RUN rpm -ivh /tmp/foo.rpm
RUN rpm -qp /tmp/foo.rpm --changelog | grep "Carlos A Becker <pkg@carlosbecker.com>"
RUN rpm -qp /tmp/foo.rpm --changelog | grep "note 1"
RUN rpm -qp /tmp/foo.rpm --changelog | grep "note 2"
RUN rpm -qp /tmp/foo.rpm --changelog | grep "note 3"
RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 1$"
RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 2$"
RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 3$"
RUN rpm -q foo --changelog | grep "Carlos A Becker <pkg@carlosbecker.com>"
RUN rpm -q foo --changelog | grep "note 1"
RUN rpm -q foo --changelog | grep "note 2"
RUN rpm -q foo --changelog | grep "note 3"
RUN rpm -q foo --changelog | grep -E "^- note 1$"
RUN rpm -q foo --changelog | grep -E "^- note 2$"
RUN rpm -q foo --changelog | grep -E "^- note 3$"
RUN rpm -e foo
6 changes: 3 additions & 3 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func createChangelog(info *nfpm.Info) (chglogTarGz []byte, err error) {
}

func formatChangelog(info *nfpm.Info) (string, error) {
pkgChglog, err := info.GetChangeLog()
changelog, err := info.GetChangeLog()
if err != nil {
return "", err
}
Expand All @@ -262,12 +262,12 @@ func formatChangelog(info *nfpm.Info) (string, error) {
return "", err
}

chglogData, err := chglog.FormatChangelog(pkgChglog, tpl)
formattedChangelog, err := chglog.FormatChangelog(changelog, tpl)
if err != nil {
return "", err
}

return chglogData, nil
return strings.TrimSpace(formattedChangelog) + "\n", nil
}

func createControl(instSize int64, md5sums []byte, info *nfpm.Info) (controlTarGz []byte, err error) {
Expand Down
2 changes: 1 addition & 1 deletion deb/deb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,5 @@ func readAndFormatAsDebChangelog(changelogFileName, packageName string) (string,
return "", err
}

return debChangelog, nil
return strings.TrimSpace(debChangelog) + "\n", nil
}
10 changes: 5 additions & 5 deletions rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const (
tagChangelogText = 1082

changelogNotesTemplate = `
{{- range .Changes }}{{$note := splitList "\n" .Note}}
- {{ first $note }}
{{- range $i,$n := (rest $note) }}{{- if ne (trim $n) ""}}
{{$n}}{{end}}
{{- end}}{{- end}}`
{{- range .Changes }}{{$note := splitList "\n" .Note}}
- {{ first $note }}
{{- range $i,$n := (rest $note) }}{{- if ne (trim $n) ""}}
{{$n}}{{end}}
{{- end}}{{- end}}`
)

// nolint: gochecknoinits
Expand Down

0 comments on commit 4f94179

Please sign in to comment.