Skip to content
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

Fix: Use Version.major instead of .epoch for git log. #48

Merged
merged 6 commits into from
Jul 30, 2024
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
6 changes: 3 additions & 3 deletions qiskit_bot/release_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _get_log_string(version_obj, version_number, repo):
# If a patch release log between 0.A.X..0.A.X-1
elif version_obj.micro > 0:
old_version = (
f"{version_obj.epoch}.{version_obj.minor}."
f"{version_obj.major}.{version_obj.minor}."
f"{version_obj.micro - 1}"
)
# If a major version log between X.0.0..x-1.y.z
Expand All @@ -240,9 +240,9 @@ def _get_log_string(version_obj, version_number, repo):
if tag_version.major == previous_major:
old_version = tag
break
# If a minor release log between 0.X.0..0.X-1.0
# If a minor release log between Y.X.0..Y.X-1.0
else:
old_version = f"{version_obj.epoch}.{version_obj.minor - 1}.0"
old_version = f"{version_obj.major}.{version_obj.minor - 1}.0"
return f"{version_number}...{old_version}"


Expand Down
94 changes: 72 additions & 22 deletions tests/test_release_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,32 +837,82 @@ def test_bump_minor_release_from_pending_patch_release_pr(self,
existing_pull_mock.edit.assert_called_once_with(
body='Fake old body\nqiskit-terra==0.16.0')

def test_get_log_string(self):
@unittest.mock.patch.object(release_process, 'git')
def test_get_log_string(self, git_mock):
version_obj = parse("0.10.2")
self.assertEqual('0.10.2...0.10.1',
release_process._get_log_string(
version_obj,
"0.10.2",
unittest.mock.MagicMock()
))
self.assertEqual(
"0.10.2...0.10.1",
release_process._get_log_string(
version_obj, "0.10.2", unittest.mock.MagicMock()
),
)
version_obj = parse("0.3.0")
self.assertEqual('0.3.0...0.2.0',
release_process._get_log_string(
version_obj,
"0.3.0",
unittest.mock.MagicMock()))
self.assertEqual(
"0.3.0...0.2.0",
release_process._get_log_string(
version_obj, "0.3.0", unittest.mock.MagicMock()
),
)
version_obj = parse("0.3.25")
self.assertEqual('0.3.25...0.3.24',
release_process._get_log_string(
version_obj,
"0.3.25",
unittest.mock.MagicMock()))
self.assertEqual(
"0.3.25...0.3.24",
release_process._get_log_string(
version_obj, "0.3.25", unittest.mock.MagicMock()
),
)
version_obj = parse("0.25.0")
self.assertEqual('0.25.0...0.24.0',
release_process._get_log_string(
version_obj,
"0.25.0",
unittest.mock.MagicMock()))
self.assertEqual(
"0.25.0...0.24.0",
release_process._get_log_string(
version_obj, "0.25.0", unittest.mock.MagicMock()
),
)
# Tests for >= 1.x.x
self.useFixture(
fake_meta.FakeMetaRepo(self.temp_dir, "1.1.0",
terra_version="1.1.1")
)
# Mock tags for 0.45-1.1.1
git_mock.get_tags.return_value = """0.46.2
1.1.1
0.46.2
1.1.1
1.1.0
1.1.0rc1
0.46.1
1.0.2
1.0.1
1.0.0
1.0.0rc1
0.46.0
0.45.3
0.45.2
1.0.0b1
0.45.1
0.45.0
"""
mock_repo = unittest.mock.MagicMock()
mock_repo.name = "qiskit"
mock_repo.repo_name = "Qiskit/qiskit"
mock_repo.repo_config = {"optional_package": False}
mock_repo.local_path = self.temp_dir.path
print(mock_repo.local_path)
print(mock_repo.gh_repo.get_tags())
raynelfss marked this conversation as resolved.
Show resolved Hide resolved
version_obj = parse("1.0.0")
self.assertEqual(
"1.0.0...0.46.2",
release_process._get_log_string(version_obj, "1.0.0", mock_repo),
)
mtreinish marked this conversation as resolved.
Show resolved Hide resolved
version_obj = parse("1.1.0")
self.assertEqual(
"1.1.0...1.0.0",
release_process._get_log_string(version_obj, "1.1.0", mock_repo),
)
version_obj = parse("1.1.1")
self.assertEqual(
"1.1.1...1.1.0",
release_process._get_log_string(version_obj, "1.1.1", mock_repo),
)

def test_get_log_string_prerelease(self):
version_obj = parse("0.25.0rc1")
Expand Down
Loading