MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / get_oldest_and_newest_rev

Function get_oldest_and_newest_rev

commitizen/changelog.py:336–369  ·  view source on GitHub ↗

Find the tags for the given version. `version` may come in different formats: - `0.1.0..0.4.0`: as a range - `0.3.0`: as a single version

(
    tags: Iterable[GitTag],
    version: str,
    rules: TagRules,
)

Source from the content-addressed store, hash-verified

334
335
336def get_oldest_and_newest_rev(
337 tags: Iterable[GitTag],
338 version: str,
339 rules: TagRules,
340) -> tuple[str | None, str]:
341 """Find the tags for the given version.
342
343 `version` may come in different formats:
344 - `0.1.0..0.4.0`: as a range
345 - `0.3.0`: as a single version
346 """
347 oldest_version, sep, newest_version = version.partition("..")
348 if not sep:
349 newest_version = version
350 oldest_version = ""
351
352 def get_tag_name(v: str) -> str:
353 if tag := rules.find_tag_for(tags, v):
354 return tag.name
355 raise NoCommitsFoundError("Could not find a valid revision range.")
356
357 newest_tag_name = get_tag_name(newest_version)
358 oldest_tag_name = get_tag_name(oldest_version) if oldest_version else None
359
360 oldest_rev = get_next_tag_name_after_version(
361 tags, oldest_tag_name or newest_tag_name
362 )
363
364 # Return None for oldest_rev if:
365 # 1. The oldest tag is the last tag in the list and matches the requested oldest tag
366 # 2. The oldest and the newest tag are the same
367 if oldest_rev == newest_tag_name:
368 return None, newest_tag_name
369 return oldest_rev, newest_tag_name

Callers

nothing calls this directly

Calls 2

get_tag_nameFunction · 0.85

Tested by

no test coverage detected