Skip to content

Commit

Permalink
Merge pull request #39 from strvcom/fix/id-gen
Browse files Browse the repository at this point in the history
release: v0.5.1
  • Loading branch information
TomasKocman authored Oct 15, 2024
2 parents 583a2f5 + 11f0881 commit 71dde73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ How to release a new version:

## [Unreleased]

## [0.5.1] - 2024-10-14
### Fixed
- Output preamble in generated file.

## [0.5.0] - 2024-10-14
### Added
- Use `debug.ReadBuildInfo` to get correct version.
Expand Down Expand Up @@ -58,7 +62,8 @@ How to release a new version:
### Added
- Added Changelog.

[Unreleased]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.5.0...HEAD
[Unreleased]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.5.1...HEAD
[0.5.1]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.3.1...v0.4.0
[0.3.1]: https://github.com/strvcom/strv-backend-go-tea/compare/v0.3.0...v0.3.1
Expand Down
12 changes: 7 additions & 5 deletions cmd/tea/gen_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import (
"github.com/spf13/cobra"
)

var (
const (
outputPreamble = "// Code generated by tea. DO NOT EDIT.\n\n"
)

var (
// genIDCmd represents the id command
genIDCmd = &cobra.Command{
Use: "id",
Expand Down Expand Up @@ -135,10 +138,6 @@ func (i IDs) generate() ([]byte, error) {
var genData []byte
var err error

if _, err = output.WriteString(outputPreamble); err != nil {
return nil, fmt.Errorf("writing output preamble: %w", err)
}

for typ := range i {
//nolint:gocritic,exhaustive
switch typ {
Expand Down Expand Up @@ -361,6 +360,9 @@ func runGenerateIDs(sourceFilePath, outputFilePath string) error {
}
}()

if _, err = outputFile.Write([]byte(outputPreamble)); err != nil {
return cmderrors.NewCommandError(fmt.Errorf("writing output preamble: %w", err), cmderrors.CodeIO)
}
if _, err = outputFile.Write(ids.generateHeader()); err != nil {
return cmderrors.NewCommandError(fmt.Errorf("writing output header: %w", err), cmderrors.CodeIO)
}
Expand Down

0 comments on commit 71dde73

Please sign in to comment.