From 141ac56975db9e35af271f73e328029d85a19795 Mon Sep 17 00:00:00 2001 From: Kasey Kirkham Date: Thu, 9 Jan 2025 08:25:26 -0600 Subject: [PATCH] enable output path to be set --- changelog/changelog.go | 1 + cmd/release/main.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog/changelog.go b/changelog/changelog.go index 14134c6..ca0f43e 100644 --- a/changelog/changelog.go +++ b/changelog/changelog.go @@ -48,6 +48,7 @@ type Config struct { Cleanup bool Branch string ReleaseTime time.Time + OutputPath string } func (c *Config) Repo() (*git.Repository, error) { diff --git a/cmd/release/main.go b/cmd/release/main.go index b6a9c4a..b78bdf9 100644 --- a/cmd/release/main.go +++ b/cmd/release/main.go @@ -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 == "" { @@ -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 } @@ -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 }