-
Notifications
You must be signed in to change notification settings - Fork 25
Add changelog_format for compatibility with multiple changelogs
#467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
IanButterworth
merged 14 commits into
JuliaRegistries:master
from
arnavk23:fix-issue-216
Jan 5, 2026
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5dd3d0f
Add auto_changelog option to use GitHub's auto-generated release notes
arnavk23 c4e6bde
Add changelog_format option with support for custom, github, and conv…
arnavk23 2c26054
Fix test failures and formatting
arnavk23 f24651e
Update tagbot/action/repo.py
arnavk23 a76f6f4
Update tagbot/action/repo.py
arnavk23 ea57959
Update test/action/test_changelog_formats.py
arnavk23 377116d
Optimize: reuse releases list to avoid duplicate API calls
arnavk23 41d5b70
Refactor: test conventional changelog through public API
arnavk23 92b0d93
Apply suggestions from code review
arnavk23 a0932b0
Add informative messages for empty conventional changelogs + fix type…
arnavk23 d45d0e4
flake8
arnavk23 5553424
flake8 - 2
arnavk23 0aaa8d5
Merge branch 'master' into fix-issue-216
IanButterworth 808ef1e
minor fixes
IanButterworth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| """Tests for auto-generated changelog feature (issue #216).""" | ||
|
|
||
| from unittest.mock import Mock, patch | ||
|
|
||
| import pytest | ||
|
|
||
arnavk23 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| from tagbot.action.repo import Repo | ||
|
|
||
|
|
||
| def _repo( | ||
| *, | ||
| repo="", | ||
| registry="", | ||
| github="", | ||
| github_api="", | ||
| token="x", | ||
| changelog="", | ||
| ignore=None, | ||
| auto_changelog=False, | ||
| ssh=False, | ||
| gpg=False, | ||
| draft=False, | ||
| registry_ssh="", | ||
| user="", | ||
| email="", | ||
| branch=None, | ||
| subdir=None, | ||
| tag_prefix=None, | ||
| ): | ||
| return Repo( | ||
| repo=repo, | ||
| registry=registry, | ||
| github=github, | ||
| github_api=github_api, | ||
| token=token, | ||
| changelog=changelog, | ||
| changelog_ignore=ignore if ignore is not None else [], | ||
| auto_changelog=auto_changelog, | ||
| ssh=ssh, | ||
| gpg=gpg, | ||
| draft=draft, | ||
| registry_ssh=registry_ssh, | ||
| user=user, | ||
| email=email, | ||
| branch=branch, | ||
| subdir=subdir, | ||
| tag_prefix=tag_prefix, | ||
| ) | ||
arnavk23 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @patch("tagbot.action.repo.Github") | ||
| def test_auto_changelog_disabled_by_default(mock_github): | ||
| """Test that auto_changelog is False by default.""" | ||
| mock_gh_instance = Mock() | ||
| mock_github.return_value = mock_gh_instance | ||
| mock_gh_instance.get_repo.return_value = Mock() | ||
|
|
||
| r = _repo(repo="test/repo", registry="test/registry") | ||
| assert r._auto_changelog is False | ||
| assert r._changelog is not None | ||
|
|
||
|
|
||
| @patch("tagbot.action.repo.Github") | ||
| def test_auto_changelog_enabled(mock_github): | ||
| """Test that auto_changelog can be enabled.""" | ||
| mock_gh_instance = Mock() | ||
| mock_github.return_value = mock_gh_instance | ||
| mock_gh_instance.get_repo.return_value = Mock() | ||
|
|
||
| r = _repo(repo="test/repo", registry="test/registry", auto_changelog=True) | ||
| assert r._auto_changelog is True | ||
| assert r._changelog is None | ||
|
|
||
|
|
||
| @patch("tagbot.action.repo.Github") | ||
| def test_create_release_with_auto_changelog(mock_github, logger): | ||
| """Test that create_release uses GitHub's auto-generated notes when enabled.""" | ||
| mock_gh_instance = Mock() | ||
| mock_github.return_value = mock_gh_instance | ||
|
|
||
| mock_repo = Mock() | ||
| mock_gh_instance.get_repo.return_value = mock_repo | ||
| mock_repo.get_releases.return_value = [] | ||
|
|
||
| r = _repo(repo="test/repo", registry="test/registry", auto_changelog=True) | ||
| r._git = Mock() | ||
| r._git.create_tag = Mock() | ||
|
|
||
| r.create_release("v1.0.0", "abc123") | ||
|
|
||
| # Verify create_git_release was called with generate_release_notes=True | ||
| mock_repo.create_git_release.assert_called_once() | ||
| call_args = mock_repo.create_git_release.call_args | ||
| assert call_args.kwargs["generate_release_notes"] is True | ||
| # Body should be empty when using auto-generated notes | ||
| assert call_args.args[2] == "" | ||
|
|
||
|
|
||
| @patch("tagbot.action.repo.Github") | ||
| def test_create_release_with_custom_changelog(mock_github, logger): | ||
| """Test that create_release uses custom changelog when auto_changelog is False.""" | ||
| mock_gh_instance = Mock() | ||
| mock_github.return_value = mock_gh_instance | ||
|
|
||
| mock_repo = Mock() | ||
| mock_gh_instance.get_repo.return_value = mock_repo | ||
| mock_repo.get_releases.return_value = [] | ||
|
|
||
| r = _repo(repo="test/repo", registry="test/registry", auto_changelog=False) | ||
| r._git = Mock() | ||
| r._git.create_tag = Mock() | ||
|
|
||
| # Mock the changelog generation | ||
| r._changelog = Mock() | ||
| r._changelog.get = Mock(return_value="Custom changelog content") | ||
|
|
||
| r.create_release("v1.0.0", "abc123") | ||
|
|
||
| # Verify changelog.get was called | ||
| r._changelog.get.assert_called_once_with("v1.0.0", "abc123") | ||
|
|
||
| # Verify create_git_release was called with generate_release_notes=False | ||
| mock_repo.create_git_release.assert_called_once() | ||
| call_args = mock_repo.create_git_release.call_args | ||
| assert call_args.kwargs["generate_release_notes"] is False | ||
| # Body should contain custom changelog | ||
| assert call_args.args[2] == "Custom changelog content" | ||
|
|
||
|
|
||
| @patch("tagbot.action.repo.Github") | ||
| def test_auto_changelog_logging(mock_github, logger, caplog): | ||
| """Test that auto_changelog logs appropriate message.""" | ||
| mock_gh_instance = Mock() | ||
| mock_github.return_value = mock_gh_instance | ||
|
|
||
| mock_repo = Mock() | ||
| mock_gh_instance.get_repo.return_value = mock_repo | ||
| mock_repo.get_releases.return_value = [] | ||
|
|
||
| r = _repo(repo="test/repo", registry="test/registry", auto_changelog=True) | ||
| r._git = Mock() | ||
| r._git.create_tag = Mock() | ||
|
|
||
| r.create_release("v1.0.0", "abc123") | ||
|
|
||
| # Check that the log message about auto-generated notes was logged | ||
| assert "Using GitHub auto-generated release notes" in caplog.text | ||
arnavk23 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.