Skip to content

Commit

Permalink
enable output path to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jan 9, 2025
1 parent de7680e commit 141ac56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
Cleanup bool
Branch string
ReleaseTime time.Time
OutputPath string
}

func (c *Config) Repo() (*git.Repository, error) {
Expand Down
6 changes: 5 additions & 1 deletion cmd/release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func parseArgs(args []string) (*changelog.Config, error) {
flags.StringVar(&c.ChangesDir, "changelog-dir", "changelog", "Path to the directory containing changelog fragments for each commit")
flags.StringVar(&c.Tag, "tag", "", "New release tag (must already exist in repo)")
flags.StringVar(&c.PreviousPath, "prev", "CHANGELOG.md", "Path to current changelog in the repo. This will be pulled from HEAD")
flags.StringVar(&c.OutputPath, "output", "", "Path to file where merged output will be written (relative to the -repo flag). Defaults to the value of the -prev flag")
flags.BoolVar(&c.Cleanup, "cleanup", false, "Remove the changelog fragment files after generating the changelog")
flags.Parse(args)
if c.RepoPath == "" {
Expand All @@ -33,6 +34,9 @@ func parseArgs(args []string) (*changelog.Config, error) {
if c.PreviousPath == "" {
return c, fmt.Errorf("prev is required")
}
if c.OutputPath == "" {
c.OutputPath = c.PreviousPath
}
return c, nil
}

Expand All @@ -45,7 +49,7 @@ func Run(ctx context.Context, args []string) error {
if err != nil {
return err
}
clPath := path.Join(cfg.RepoPath, cfg.PreviousPath)
clPath := path.Join(cfg.RepoPath, cfg.OutputPath)
if err := os.WriteFile(clPath, []byte(out), 0644); err != nil {
return err
}
Expand Down

0 comments on commit 141ac56

Please sign in to comment.