From 464aea8073ef7a46684b15ee570e89bccfba1e86 Mon Sep 17 00:00:00 2001 From: Andrew Herron Date: Mon, 30 Oct 2023 16:39:21 +1100 Subject: [PATCH] Merge unreleased now only merges project-specific changes into each project. (#570) * Pass project name when getting unreleased changes for merge * Release v1.15.1 for the fix --------- Co-authored-by: Ronnie Smith --- .changes/v1.15.1.md | 5 ++++ CHANGELOG.md | 6 ++++ cmd/merge.go | 2 +- cmd/merge_test.go | 60 +++++++++++++++++++++++++++++++++++++++- docs/config.toml | 2 +- docs/static/version.json | 2 +- package.json | 2 +- 7 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 .changes/v1.15.1.md diff --git a/.changes/v1.15.1.md b/.changes/v1.15.1.md new file mode 100644 index 00000000..490a2f02 --- /dev/null +++ b/.changes/v1.15.1.md @@ -0,0 +1,5 @@ +## v1.15.1 on 2023-10-29 + +### Fixed + +* [#569](https://github.com/miniscruff/changie/issues/569) Merge unreleased now only merges project-specific changes into each project. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8833f721..499b050f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [itself](https://github.com/miniscruff/changie). +## v1.15.1 on 2023-10-29 + +### Fixed + +* [#569](https://github.com/miniscruff/changie/issues/569) Merge unreleased now only merges project-specific changes into each project. + ## v1.15.0 on 2023-10-27 ### Added diff --git a/cmd/merge.go b/cmd/merge.go index 95907d09..9c99447a 100644 --- a/cmd/merge.go +++ b/cmd/merge.go @@ -127,7 +127,7 @@ func (m *Merge) mergeProject(cfg *core.Config, project, changelogPath string) er nil, m.ReadDir, m.ReadFile, - "", + project, ) if unrelErr != nil { return unrelErr diff --git a/cmd/merge_test.go b/cmd/merge_test.go index daddc90c..e1fa1ee3 100644 --- a/cmd/merge_test.go +++ b/cmd/merge_test.go @@ -104,7 +104,7 @@ first version then.FileContents(t, changeContents, "a", "thing", "CHANGELOG.md") } -func TestMergeVersionsErrorInvalidProject(t *testing.T) { +func TestMergeVersionsErrorMissingProjectDir(t *testing.T) { cfg := mergeTestConfig() cfg.HeaderPath = "" cfg.Replacements = nil @@ -220,6 +220,64 @@ func TestMergeVersionsWithUnreleasedChangesErrorsOnBadChangeFormat(t *testing.T) then.NotNil(t, err) } +func TestMergeVersionsWithUnreleasedChangesInOneProject(t *testing.T) { + cfg := mergeTestConfig() + cfg.HeaderPath = "" + cfg.Replacements = nil + cfg.Projects = []core.ProjectConfig{ + { + Label: "A thing", + Key: "a", + ChangelogPath: "a/thing/CHANGELOG.md", + }, + { + Label: "B thing", + Key: "b", + ChangelogPath: "b/thing/CHANGELOG.md", + }, + } + then.WithTempDirConfig(t, cfg) + + then.WriteFile(t, []byte("first A version\n"), cfg.ChangesDir, "a", "v0.1.0.md") + then.WriteFile(t, []byte("second A version\n"), cfg.ChangesDir, "a", "v0.2.0.md") + then.Nil(t, os.MkdirAll(filepath.Join("a", "thing"), core.CreateDirMode)) + then.WriteFile(t, []byte("first B version\n"), cfg.ChangesDir, "b", "v0.1.0.md") + then.WriteFile(t, []byte("second B version\n"), cfg.ChangesDir, "b", "v0.2.0.md") + then.Nil(t, os.MkdirAll(filepath.Join("b", "thing"), core.CreateDirMode)) + + unrel := core.Change{ + Kind: "Added", + Body: "new feature coming soon", + Project: "a", + } + writeChangeFile(t, cfg, &unrel) + + cmd := NewMerge( + os.ReadFile, + os.WriteFile, + os.ReadDir, + os.Open, + os.Create, + core.NewTemplateCache(), + ) + cmd.UnreleasedHeader = "## Coming Soon" + err := cmd.Run(cmd.Command, nil) + then.Nil(t, err) + + changeContentsA := `## Coming Soon +### Added +* new feature coming soon +second A version +first A version +` + then.FileContents(t, changeContentsA, "a", "thing", "CHANGELOG.md") + + changeContentsB := `second B version +first B version +` + then.FileContents(t, changeContentsB, "b", "thing", "CHANGELOG.md") +} + func TestMergeVersionsWithHeaderAndReplacements(t *testing.T) { cfg := mergeTestConfig() then.WithTempDirConfig(t, cfg) diff --git a/docs/config.toml b/docs/config.toml index 49e569a2..9f4768fb 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -46,7 +46,7 @@ summaryLength = 30 ] enable_anchor_link = true issues_url = 'https://github.com/miniscruff/changie/issues/new' - version = 'v1.15.0' + version = 'v1.15.1' [params.homepage_meta_tags] meta_description = "Changie is a file based changelog management tool." diff --git a/docs/static/version.json b/docs/static/version.json index 53a728a3..1ae8e3ea 100644 --- a/docs/static/version.json +++ b/docs/static/version.json @@ -1,3 +1,3 @@ { - "latest": "v1.15.0" + "latest": "v1.15.1" } diff --git a/package.json b/package.json index 16416bff..73227f53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "changie", - "version": "1.15.0", + "version": "1.15.1", "author": "miniscruff", "description": "Automated changelog tool for preparing releases with lots of customization options", "bin": {