Skip to content

Commit

Permalink
overwrite changelog (rather than write to stdout)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jan 9, 2025
1 parent 10c36de commit de7680e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"flag"
"fmt"
"os"
"path"
"time"

"github.com/OffchainLabs/unclog/changelog"
Expand All @@ -19,7 +21,11 @@ func parseArgs(args []string) (*changelog.Config, error) {
flags.BoolVar(&c.Cleanup, "cleanup", false, "Remove the changelog fragment files after generating the changelog")
flags.Parse(args)
if c.RepoPath == "" {
return c, fmt.Errorf("repo is required")
wd, err := os.Getwd()
if err != nil {
return nil, fmt.Errorf("repo flag not set and can't get working directory from syscall, %w", err)
}
c.RepoPath = wd
}
if c.Tag == "" {
return c, fmt.Errorf("tag is required")
Expand All @@ -39,6 +45,9 @@ func Run(ctx context.Context, args []string) error {
if err != nil {
return err
}
fmt.Println(out)
clPath := path.Join(cfg.RepoPath, cfg.PreviousPath)
if err := os.WriteFile(clPath, []byte(out), 0644); err != nil {
return err
}
return nil
}

0 comments on commit de7680e

Please sign in to comment.