Make autogenerated version independent from tweak by default

This commit is contained in:
Mikhail f. Shiryaev 2023-02-24 12:05:21 +01:00
parent 54d46f2180
commit ad7ec74009
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
2 changed files with 24 additions and 20 deletions

View File

@ -265,7 +265,11 @@ class Release:
f"for {self.release_type} release"
)
def _commit_cmake_contributors(self, version: ClickHouseVersion) -> None:
def _update_cmake_contributors(
self, version: ClickHouseVersion, reset_tweak: bool = True
) -> None:
if reset_tweak:
version = version.reset_tweak()
update_cmake_version(version)
update_contributors(raise_error=True)
if self.dry_run:
@ -274,9 +278,15 @@ class Release:
self.run(f"git diff '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'"),
)
self.run(f"git checkout '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'")
def _commit_cmake_contributors(
self, version: ClickHouseVersion, reset_tweak: bool = True
) -> None:
if reset_tweak:
version = version.reset_tweak()
self.run(
f"git commit -m 'Update version to {version.string}' "
f"'{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'",
f"git commit '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}' "
f"-m 'Update autogenerated version to {version.string} and contributors'",
dry_run=self.dry_run,
)
@ -321,27 +331,12 @@ class Release:
with self._create_gh_release(False):
self.version = self.version.update(self.release_type)
self.version.with_description(version_type)
update_cmake_version(self.version)
update_contributors(raise_error=True)
if self.dry_run:
logging.info(
"Dry running, resetting the following changes in the repo:\n%s",
self.run(
f"git diff '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'"
),
)
self.run(f"git checkout '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'")
self._update_cmake_contributors(self.version)
# Checkouting the commit of the branch and not the branch itself,
# then we are able to skip rollback
with self._checkout(f"{self.release_branch}^0", False):
current_commit = self.run("git rev-parse HEAD")
self.run(
f"git commit -m "
f"'Update version to {self.version.string}' "
f"'{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'",
dry_run=self.dry_run,
)
self._commit_cmake_contributors(self.version)
with self._push(
"HEAD", with_rollback_on_fail=False, remote_ref=self.release_branch
):
@ -406,6 +401,7 @@ class Release:
if version_type == VersionType.LTS:
pr_labels += " --label release-lts"
new_version.with_description(version_type)
self._update_cmake_contributors(new_version)
self._commit_cmake_contributors(new_version)
with self._push(self.release_branch):
with self._create_gh_label(
@ -434,6 +430,7 @@ class Release:
self.read_version()
self.version = self.version.update(self.release_type)
self.version.with_description(VersionType.TESTING)
self._update_cmake_contributors(self.version)
self._commit_cmake_contributors(self.version)
with self._push(helper_branch):
body_file = get_abs_path(".github/PULL_REQUEST_TEMPLATE.md")

View File

@ -88,6 +88,13 @@ class ClickHouseVersion:
self.major, self.minor, self.patch + 1, self.revision, self._git
)
def reset_tweak(self) -> "ClickHouseVersion":
if self._git is not None:
self._git.update()
return ClickHouseVersion(
self.major, self.minor, self.patch, self.revision, self._git, "1"
)
@property
def major(self) -> int:
return self._major