Skip to content

Commit

Permalink
🐛 Fix handling multiple section headers (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo authored Nov 2, 2023
1 parent 6889b65 commit 113bc12
Show file tree
Hide file tree
Showing 3 changed files with 361 additions and 40 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,6 @@ So, the commits will still be shown as made by `github-actions`.

* ✏️ Fix typo in syntax for using the GitHub Action tag directly (instead of with Docker) in README. PR [#39](https://github.com/tiangolo/latest-changes/pull/39) by [@art049](https://github.com/art049).

#### Internal

* ⬆ Bump docker/setup-buildx-action from 1 to 3. PR [#53](https://github.com/tiangolo/latest-changes/pull/53) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump docker/build-push-action from 2 to 5. PR [#52](https://github.com/tiangolo/latest-changes/pull/52) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump docker/login-action from 1 to 3. PR [#51](https://github.com/tiangolo/latest-changes/pull/51) by [@dependabot[bot]](https://github.com/apps/dependabot).

### 0.1.0

#### Features
Expand Down
21 changes: 11 additions & 10 deletions latest_changes/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ def generate_content(
sections: list[SectionContent] = []
sectionless_content = ""
for label in settings.input_labels:
label_match = re.search(label.header, release_content)
label_match = re.search(label.header, release_content, flags=re.MULTILINE)
if not label_match:
continue
next_label_match = re.search(
settings.input_next_section_start, release_content[label_match.end() :]
settings.input_next_section_start,
release_content[label_match.end() :],
flags=re.MULTILINE,
)
label_section_end = (
len(release_content)
Expand Down Expand Up @@ -158,20 +160,19 @@ def generate_content(
new_release_content = ""
if sectionless_content:
new_release_content = f"{sectionless_content}"
updated_content = "\n\n".join(
[
f"{section.header}\n\n{section.content}"
for section in new_sections
if section.content
]
)
use_sections = [
f"{section.header}\n\n{section.content}"
for section in new_sections
if section.content
]
updated_content = "\n\n".join(use_sections)
if new_release_content:
if updated_content:
new_release_content += f"\n\n{updated_content}"
else:
new_release_content = updated_content

new_content = f"{pre_header_content}\n\n{new_release_content}\n\n{post_release_content}".strip()
new_content = f"{pre_header_content}\n\n{new_release_content}\n\n{post_release_content}".strip() + "\n"
return new_content


Expand Down
Loading

0 comments on commit 113bc12

Please sign in to comment.