Skip to content

Commit

Permalink
Avoid output of changie latest having an extra newline character (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Ronnie <[email protected]>
  • Loading branch information
edgarrmondragon and miniscruff authored Dec 20, 2022
1 parent 60330d2 commit efa323b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changes/v1.10.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## v1.10.2 on 2022-12-19

### Fixed

* [#430](https://github.com/miniscruff/changie/issues/430) Remove extra newline character from the output of `changie latest`
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [itself](https://github.com/miniscruff/changie).

## v1.10.2 on 2022-12-19

### Fixed

* [#430](https://github.com/miniscruff/changie/issues/430) Remove extra newline character from the output of `changie latest`

## v1.10.1 on 2022-12-11

### Fixed
Expand Down
5 changes: 2 additions & 3 deletions cmd/latest.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"fmt"
"strings"

"github.com/spf13/afero"
Expand Down Expand Up @@ -66,8 +65,8 @@ func latestPipeline(afs afero.Afero, skipPrereleases bool) (string, error) {
}

if removePrefix {
return fmt.Sprintln(strings.TrimPrefix(ver.Original(), "v")), nil
return strings.TrimPrefix(ver.Original(), "v"), nil
}

return fmt.Sprintln(ver.Original()), nil
return ver.Original(), nil
}
6 changes: 3 additions & 3 deletions cmd/latest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("Latest", func() {
removePrefix = false
res, err := latestPipeline(afs, false)
Expect(err).To(BeNil())
Expect(res).To(Equal("v0.2.0-rc1\n"))
Expect(res).To(Equal("v0.2.0-rc1"))
})

It("echos latest version not a prerelease", func() {
Expand All @@ -62,7 +62,7 @@ var _ = Describe("Latest", func() {
removePrefix = false
res, err := latestPipeline(afs, true)
Expect(err).To(BeNil())
Expect(res).To(Equal("v0.1.0\n"))
Expect(res).To(Equal("v0.1.0"))
})

It("echos latest version without prefix", func() {
Expand All @@ -76,7 +76,7 @@ var _ = Describe("Latest", func() {
removePrefix = true
res, err := latestPipeline(afs, false)
Expect(err).To(BeNil())
Expect(res).To(Equal("0.1.0\n"))
Expect(res).To(Equal("0.1.0"))
})

It("fails if bad config file", func() {
Expand Down
2 changes: 1 addition & 1 deletion docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ summaryLength = 30
]
enable_anchor_link = true
issues_url = 'https://github.com/miniscruff/changie/issues/new'
version = 'v1.10.1'
version = 'v1.10.2'

[params.homepage_meta_tags]
meta_description = "Changie is a file based changelog management tool."
Expand Down

0 comments on commit efa323b

Please sign in to comment.