Skip to content

Commit

Permalink
style: beautify 8b742d3
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 8, 2024
1 parent 8b742d3 commit f95be0c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions semantic_release/version/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _bfs_for_latest_version_in_history(
tag_sha_2_version_lookup = {
tag.commit.hexsha: version for tag, version in full_release_tags_and_versions
}

# Step 3. Latest full release version within the history of the current branch
# Breadth-first search the merge-base and its parent commits for one which matches
# the tag of the latest full release tag in history
Expand Down
42 changes: 29 additions & 13 deletions tests/unit/semantic_release/version/test_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,47 @@ def test_bfs_for_latest_version_in_history():
repo = Repo()
expected_version = Version.parse("1.0.0")
v1_commit = Commit(repo, binsha=b"0" * 20)

class TagReferenceOverride(TagReference):
commit = v1_commit # type: ignore - mocking the commit property
commit = v1_commit # type: ignore - mocking the commit property

v1_tag = TagReferenceOverride(repo, "refs/tags/v1.0.0", check_path=False)

trunk = Commit(repo, binsha=b"3" * 20, parents=[
Commit(repo, binsha=b"2" * 20, parents=[
Commit(repo, binsha=b"1" * 20, parents=[v1_commit]),
]),
])
trunk = Commit(
repo,
binsha=b"3" * 20,
parents=[
Commit(
repo,
binsha=b"2" * 20,
parents=[
Commit(repo, binsha=b"1" * 20, parents=[v1_commit]),
],
),
],
)
start_commit = Commit(
repo,
binsha=b"6" * 20,
parents=[
trunk,
Commit(repo, binsha=b"5" * 20, parents=[
Commit(repo, binsha=b"4" * 20, parents=[trunk]),
]),
]
Commit(
repo,
binsha=b"5" * 20,
parents=[
Commit(repo, binsha=b"4" * 20, parents=[trunk]),
],
),
],
)

# Execute
actual = _bfs_for_latest_version_in_history(start_commit, [
(v1_tag, expected_version),
])
actual = _bfs_for_latest_version_in_history(
start_commit,
[
(v1_tag, expected_version),
],
)

# Verify
assert expected_version == actual
Expand Down

0 comments on commit f95be0c

Please sign in to comment.