diff --git a/sphinx_github_changelog/changelog.py b/sphinx_github_changelog/changelog.py index 35e5380..5aff59f 100644 --- a/sphinx_github_changelog/changelog.py +++ b/sphinx_github_changelog/changelog.py @@ -99,6 +99,10 @@ def extract_pypi_package_name(url: Optional[str]) -> Optional[str]: return stripped_url[len(prefix) :] # noqa +def get_release_title(title: Optional[str], tag: str): + if not title: + return tag + return title if tag in title else f"{tag}: {title}" def node_for_release( release: Dict[str, Any], pypi_name: Optional[str] = None @@ -109,7 +113,7 @@ def node_for_release( tag = release["tagName"] title = release["name"] date = release["publishedAt"][:10] - title = title if tag in title else f"{tag}: {title}" + title = get_release_title(title=title, tag=tag) # Section id_section = nodes.make_id("release-" + tag) diff --git a/tests/unit/test_changelog.py b/tests/unit/test_changelog.py index b5ed70a..274ae75 100644 --- a/tests/unit/test_changelog.py +++ b/tests/unit/test_changelog.py @@ -155,6 +155,13 @@ def test_node_for_release_title_tag(release_dict): changelog.node_for_release(release=release_dict, pypi_name=None) ) +def test_node_for_release_none_title(release_dict): + + release_dict["name"] = None + assert "