-
-
Notifications
You must be signed in to change notification settings - Fork 301
refactor(changelog): simplify logic for get_oldest_and_newest_rev #1539
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
refactor(changelog): simplify logic for get_oldest_and_newest_rev #1539
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v4-9-0-test #1539 +/- ##
==============================================
Coverage ? 98.31%
==============================================
Files ? 58
Lines ? 2669
Branches ? 0
==============================================
Hits ? 2624
Misses ? 45
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0b7774c
to
7316c2f
Compare
commitizen/changelog.py
Outdated
def get_next_tag_name_after_version(tags: Iterable[GitTag], version: str) -> str | None: | ||
a, b = tee(chain((tag.name for tag in tags), [None])) | ||
next(b, None) | ||
try: | ||
return next(y for x, y in zip(a, b) if x == version) | ||
except StopIteration: | ||
raise NoCommitsFoundError(f"Could not find a valid revision range. {version=}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gbaian10 for reminding me here we don't have to use a while loop.
1d9f4ab
to
277d8f9
Compare
277d8f9
to
83f52ac
Compare
83f52ac
to
b1d3821
Compare
Original "push" stage has been deprecated since pre-commit v3.2.0. See pre-commit/pre-commit#2732 and pre-commit/pre-commit#2808 for detailed information.
…rk unused for get_smart_tag_range
b1d3821
to
b8e19f8
Compare
Description
get_oldest_and_newest_rev
get_smart_range
, I believe we can replace it with a simpler function.get_next_tag_name_after_version
is based on an assumption that "all GitTags are unique". If the oldest tag's name is the inputversion
, then it returnsNone
. The behavior aligns with "ReturnNone
foroldest_rev
if the oldest tag is the last tag in the list and matches the requested oldest tag"Checklist
Code Changes
poetry all
locally to ensure this change passes linter check and tests