Skip to content

Commit

Permalink
feat: include a warning about generated files when generating files 💪
Browse files Browse the repository at this point in the history
I recently landed myself in an `id_gen.go` file using IDE's Go To Definition and started making updates, not noticing that it was a generated file.

This preamble would probably not help me because the file was long but perhaps it will help someone else. 🤷‍♂️
  • Loading branch information
robertrossmann committed Nov 4, 2023
1 parent 08bb6a8 commit add203c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ How to release a new version:
- Manually release new version.

## [Unreleased]
### Added
- `gen_id` now includes a comment at the top of the generated file to warn developers that the file is, in fact, generated.

## [0.4.0] - 2023-03-27
### Added
Expand Down
5 changes: 5 additions & 0 deletions cmd/tea/gen_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
)

var (
outputPreamble = "// Code generated by tea. DO NOT EDIT.\n\n"
// genIDCmd represents the id command
genIDCmd = &cobra.Command{
Use: "id",
Expand Down Expand Up @@ -141,6 +142,10 @@ 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

0 comments on commit add203c

Please sign in to comment.