Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
python modify_changelog.py update_changelog \
"${{ github.event.pull_request.number }}" \
"${{ github.event.pull_request.title }}"
'${{ github.event.pull_request.title }}'

- name: Check for changes
id: changes
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _This project uses semantic versioning_

## UNRELEASED

- [WIP] Fix automatic generic of changelog entries with markdown [#317](https://github.com/egraphs-good/egglog-python/pull/317)
- Automatically Create Changelog Entry for PRs [#313](https://github.com/egraphs-good/egglog-python/pull/313)
- Upgrade egglog which includes new backend.
- Fixes implementation of the Python Object sort to work with objects with dupliating hashes but the same value.
Expand Down
99 changes: 99 additions & 0 deletions python/tests/test_modify_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,102 @@ def test_custom_changelog_path():
# Check changelog was updated
updated_changelog = custom_changelog_path.read_text()
assert "- Add new feature [#456](https://github.com/egraphs-good/egglog-python/pull/456)" in updated_changelog


def test_update_changelog_with_markdown_backticks():
"""Test that PR titles with markdown backticks are preserved correctly."""
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)

# Create mock changelog
changelog_content = """# Changelog

## UNRELEASED

## 1.2.3 (2024-01-01)

- Some old change
"""
docs_dir = temp_path / "docs"
docs_dir.mkdir()
changelog_path = docs_dir / "changelog.md"
changelog_path.write_text(changelog_content)

# Test with title containing markdown backticks
pr_title_with_backticks = "Support methods like `__array_function__` on expressions"

# Run the script
result = subprocess.run(
[
sys.executable,
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
"update_changelog",
"315",
pr_title_with_backticks,
],
capture_output=True,
text=True,
cwd=temp_path,
check=False,
)

assert result.returncode == 0
assert f"Added changelog entry for PR #315: {pr_title_with_backticks}" in result.stdout

# Check that backticks are preserved in the changelog
updated_changelog = changelog_path.read_text()
expected_entry = f"- {pr_title_with_backticks} [#315](https://github.com/egraphs-good/egglog-python/pull/315)"
assert expected_entry in updated_changelog

# Specifically check that the backticks around __array_function__ are preserved
assert "`__array_function__`" in updated_changelog


def test_update_changelog_multiple_backticks():
"""Test that PR titles with multiple markdown elements are preserved correctly."""
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)

# Create mock changelog
changelog_content = """# Changelog

## UNRELEASED

## 1.2.3 (2024-01-01)

- Some old change
"""
docs_dir = temp_path / "docs"
docs_dir.mkdir()
changelog_path = docs_dir / "changelog.md"
changelog_path.write_text(changelog_content)

# Test with title containing multiple markdown elements
pr_title_complex = "Fix `__getattr__` and add support for `__setitem__` methods"

# Run the script
result = subprocess.run(
[
sys.executable,
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
"update_changelog",
"999",
pr_title_complex,
],
capture_output=True,
text=True,
cwd=temp_path,
check=False,
)

assert result.returncode == 0
assert f"Added changelog entry for PR #999: {pr_title_complex}" in result.stdout

# Check that all backticks are preserved in the changelog
updated_changelog = changelog_path.read_text()
expected_entry = f"- {pr_title_complex} [#999](https://github.com/egraphs-good/egglog-python/pull/999)"
assert expected_entry in updated_changelog

# Specifically check that both sets of backticks are preserved
assert "`__getattr__`" in updated_changelog
assert "`__setitem__`" in updated_changelog