Repository: mdwint/ocdc (language: python)

Issue:
Merging duplicated sections leaves whitespace
Example:

```markdown
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 0.1.0 - 2022-08-10

### Added

- Initial version.

### Changed 

- Something changed.

### Added

- Another added item.
```
 becomes

```markdown
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 0.1.0 - 2022-08-10

### Added

- Initial version.
- Another added item.




### Changed

- Something changed.
```



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 299201c..b33f85e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 
+## 0.3.3 - 2022-08-10
+
+### Fixed
+
+- Don't introduce newlines when merging duplicate changes sections.
+
+
 ## 0.3.2 - 2022-08-05
 
 ### Fixed
diff --git a/ocdc/__init__.py b/ocdc/__init__.py
index f9aa3e1..e19434e 100644
--- a/ocdc/__init__.py
+++ b/ocdc/__init__.py
@@ -1,1 +1,1 @@
-__version__ = "0.3.2"
+__version__ = "0.3.3"
diff --git a/ocdc/ast.py b/ocdc/ast.py
index 9c80f7d..6540ba9 100644
--- a/ocdc/ast.py
+++ b/ocdc/ast.py
@@ -24,7 +24,7 @@ class Changes(BaseModel):
 
     def merge(self, other: "Changes") -> None:
         self.items.extend(other.items)
-        self.footer += "\n" + other.footer
+        self.footer = f"{self.footer}\n{other.footer}".strip()
 
 
 class Version(BaseModel):
diff --git a/pyproject.toml b/pyproject.toml
index 7c51fed..af61ec4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "ocdc"
-version = "0.3.2"
+version = "0.3.3"
 description = 'A changelog formatter for "people", neat freaks, and sloppy typists.'
 authors = ["Matteo De Wint <matteo@mailfence.com>"]
 packages = [{ include = "ocdc" }]
diff --git a/setup.cfg b/setup.cfg
index f9ad8c8..b1d4f55 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 0.3.2
+current_version = 0.3.3
 commit = True
 
 [flake8]


Test patch:
diff --git a/tests/data/duplicate_changes_sections.ast.json b/tests/data/duplicate_changes_sections.ast.json
index a8b322f..144b14c 100644
--- a/tests/data/duplicate_changes_sections.ast.json
+++ b/tests/data/duplicate_changes_sections.ast.json
@@ -2,6 +2,53 @@
   "title": "Changelog",
   "intro": "All notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).",
   "versions": [
+    {
+      "number": "0.3.0",
+      "date": "2022-08-10",
+      "changes": {
+        "Added": {
+          "items": [
+            {
+              "text": "Initial version."
+            },
+            {
+              "text": "Another added item."
+            }
+          ],
+          "footer": "[one]: http://example.com/one"
+        },
+        "Changed": {
+          "items": [
+            {
+              "text": "Something changed."
+            }
+          ]
+        }
+      }
+    },
+    {
+      "number": "0.2.0",
+      "date": "2022-08-10",
+      "changes": {
+        "Added": {
+          "items": [
+            {
+              "text": "Initial version."
+            },
+            {
+              "text": "Another added item."
+            }
+          ]
+        },
+        "Changed": {
+          "items": [
+            {
+              "text": "Something changed."
+            }
+          ]
+        }
+      }
+    },
     {
       "number": "0.1.0",
       "date": "2022-07-31",
diff --git a/tests/data/duplicate_changes_sections.in.md b/tests/data/duplicate_changes_sections.in.md
index 6c4486e..ffa6078 100644
--- a/tests/data/duplicate_changes_sections.in.md
+++ b/tests/data/duplicate_changes_sections.in.md
@@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## 0.3.0 - 2022-08-10
+
+### Added
+
+- Initial version.
+
+### Changed
+
+- Something changed.
+
+### Added
+
+- Another added item.
+
+[one]: http://example.com/one
+
+## 0.2.0 - 2022-08-10
+
+### Added
+
+- Initial version.
+
+### Changed
+
+- Something changed.
+
+### Added
+
+- Another added item.
+
 ## 0.1.0 - 2022-07-31
 
 ### Added
diff --git a/tests/data/duplicate_changes_sections.out.md b/tests/data/duplicate_changes_sections.out.md
index df4d20c..e224ba7 100644
--- a/tests/data/duplicate_changes_sections.out.md
+++ b/tests/data/duplicate_changes_sections.out.md
@@ -6,6 +6,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 
+## 0.3.0 - 2022-08-10
+
+### Added
+
+- Initial version.
+- Another added item.
+
+[one]: http://example.com/one
+
+### Changed
+
+- Something changed.
+
+
+## 0.2.0 - 2022-08-10
+
+### Added
+
+- Initial version.
+- Another added item.
+
+### Changed
+
+- Something changed.
+
+
 ## 0.1.0 - 2022-07-31
 
 ### Added