diff --git a/pontos/version/commands/_java.py b/pontos/version/commands/_java.py index 3812c518..065e2cee 100644 --- a/pontos/version/commands/_java.py +++ b/pontos/version/commands/_java.py @@ -24,13 +24,10 @@ from ..errors import VersionError from ..version import Version, VersionUpdate -VERSION_PATTERN = ( - r"^(?P
.*[^\d])(?P\d+\.\d+\.\d+(-?([ab]|rc|alpha|beta)\d+(.dev\d+)?)?)(?P .*$)" -) +VERSION_PATTERN = r"^(?P .*[^\d])(?P\d+\.\d+\.\d+(-?([ab]|rc|alpha|beta)\d+(.dev\d+)?)?)(?P .*$)" # This class is used for Java Version command(s) class JavaVersionCommand(VersionCommand): - project_file_name = "upgradeVersion.json" def get_current_version(self) -> Version: @@ -44,7 +41,7 @@ def get_current_version(self) -> Version: return self.versioning_scheme.parse_version(last_version) def verify_version( - self, version: Union[Literal["current"], Version, None] + self, version: Union[Literal["current"], Version, None] ) -> None: file_versions = self._read_versions_from_files() @@ -58,7 +55,7 @@ def verify_version( ) def update_version( - self, new_version: Version, *, force: bool = False + self, new_version: Version, *, force: bool = False ) -> VersionUpdate: try: current_version = self.get_current_version() @@ -82,7 +79,7 @@ def _update_version_files(self, new_version) -> List[Path]: changed_files: List[Path] = [] for file_config in config["files"]: file_path = file_config["path"] - with open(Path.cwd() / file_path, "r") as input_file_handle: + with ((open(Path.cwd() / file_path, "r") as input_file_handle)): lines = input_file_handle.readlines() line_number = file_config["line"] version_line = lines[line_number - 1] @@ -95,7 +92,11 @@ def _update_version_files(self, new_version) -> List[Path]: f"lineNo:{line_number} " f"content:'{version_line}'" ) - lines[line_number - 1] = matches.group("pre") + str(new_version) + matches.group("post") + lines[line_number - 1] = ( + matches.group("pre") + + str(new_version) + + matches.group("post") + ) content = "".join(lines) with open(Path.cwd() / file_path, "w") as output_file_handle: