Skip to content

refactor(changelog): cleanup and add test cases #1425

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

Open
wants to merge 2 commits into
base: refactors
Choose a base branch
from

Conversation

bearomorphism
Copy link
Contributor

@bearomorphism bearomorphism commented May 17, 2025

Description

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly

Expected Behavior

Steps to Test This Pull Request

Additional Context

Copy link

codecov bot commented May 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.81%. Comparing base (59fd3f5) to head (e848508).

Additional details and impacted files
@@              Coverage Diff              @@
##           refactors    #1425      +/-   ##
=============================================
- Coverage      97.82%   97.81%   -0.01%     
=============================================
  Files             57       57              
  Lines           2619     2614       -5     
=============================================
- Hits            2562     2557       -5     
  Misses            57       57              
Flag Coverage Δ
unittests 97.81% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bearomorphism bearomorphism force-pushed the refactor-changelog-2 branch 2 times, most recently from b3dac29 to 949b496 Compare May 17, 2025 10:42
def test_get_smart_tag_range_returns_an_empty_list_for_nonexistent_start_tag(tags):
end = tags[0]
res = changelog.get_smart_tag_range(tags, "nonexistent", end.name)
assert res[0].name == tags[1].name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the expected behavior

@bearomorphism bearomorphism force-pushed the refactor-changelog-2 branch from 1d03ae8 to 12166d6 Compare May 19, 2025 13:01
@@ -114,7 +111,7 @@ def generate_tree_from_commits(
and commit_tag not in used_tags
and rules.include_in_changelog(commit_tag)
):
used_tags.append(commit_tag)
used_tags.add(commit_tag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add only tags that are not None?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to handle current_tag in this case as well 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm

@@ -170,21 +167,23 @@ def process_commit_message(
changes: dict[str | None, list],
change_type_map: dict[str, str] | None = None,
):
message: dict = {
message = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I know why we're removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure when it's necessary to explicitly annotate variable types in Python, since the type is often inferred from the assigned value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added dict[str, str | list[str] | Any] here

@@ -41,6 +41,9 @@ def __eq__(self, other) -> bool:
return False
return self.rev == other.rev # type: ignore

def __hash__(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is for used_tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@@ -337,17 +349,17 @@ def get_oldest_and_newest_rev(
if not tags_range:
raise NoCommitsFoundError("Could not find a valid revision range.")

oldest_rev: str | None = tags_range[-1].name
oldest_rev = tags_range[-1].name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I know why we want to remove the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of oldest_rev here is actually str, so I removed it.

But I just pushed another refactor to make the type annotation reasonable.

return []

if not has_newest:
return tags[1:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Why is the 1 here? I must admit that I'm not that familiar with this part 🤦‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember I was trying to align the behavior before and after the refactoring

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can hold off this part and separate it in another PR though. The algorithm here is a bit confusing.

@bearomorphism bearomorphism force-pushed the refactor-changelog-2 branch from 12166d6 to 5440afd Compare May 28, 2025 05:15
@bearomorphism bearomorphism force-pushed the refactor-changelog-2 branch 2 times, most recently from dad215f to 1ae2d12 Compare May 28, 2025 06:46
@bearomorphism bearomorphism force-pushed the refactor-changelog-2 branch from 1ae2d12 to e848508 Compare May 31, 2025 18:27
@bearomorphism bearomorphism changed the base branch from master to refactors May 31, 2025 18:27
@bearomorphism bearomorphism requested a review from Lee-W May 31, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants