Skip to content

Commit

Permalink
detect and discard template
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Jan 21, 2025
1 parent a08dacf commit 58c75ee
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions .github/scripts/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,11 @@ def summary(msg: str) -> None:
def main(pr: str, changelog: str, verbose: bool) -> None:
"""Perform quality assurance on pull-request changelog news fragment/s."""
debug(f"argument: pr=<{pr}>", verbose=verbose)
debug(f"argument: changes=<{changelog}>", verbose=verbose)
debug(f"argument: changelog=<{changelog}>", verbose=verbose)

if not len(pr):
failure("Unable to collect PR number.")

if not len(changelog):
failure(
"Please provide a **changelog news fragment file** for "
f"**[PR#{pr}]({PULL}/{pr})**."
)

try:
# locate and parse the towncrier configuration
base_directory, config = load_config_from_options(
Expand Down Expand Up @@ -249,6 +243,17 @@ def main(pr: str, changelog: str, verbose: bool) -> None:
]
debug(f"{fragments=}", verbose=verbose)

# detect and discard towncrier template from the candidate news fragments
template = Path(config.template).name
fragments = [fragment for fragment in fragments if fragment != template]
debug(f"{fragments=}", verbose=verbose)

if not len(fragments):
failure(
"Please provide a **changelog news fragment file** for "
f"**[PR#{pr}]({PULL}/{pr})**."
)

# bad news fragment buckets
bad = BadFragment()

Expand Down

0 comments on commit 58c75ee

Please sign in to comment.