Fix pylint messages for repo
This commit is contained in:
parent
6da4b3c27a
commit
82279011fa
1 changed files with 33 additions and 32 deletions
|
@ -23,9 +23,8 @@ class VersionRepository:
|
|||
|
||||
def write_file(self, version_string):
|
||||
if self.file_handler is None:
|
||||
raise Exception("Version was not created by load_file method.")
|
||||
else:
|
||||
self.file_handler.write(version_string)
|
||||
raise RuntimeError("Version was not created by load_file method.")
|
||||
self.file_handler.write(version_string)
|
||||
|
||||
def parse_file(self):
|
||||
version_list, is_snapshot = self.file_handler.parse()
|
||||
|
@ -53,29 +52,30 @@ class ReleaseTypeRepository:
|
|||
|
||||
@classmethod
|
||||
def from_git(cls, git_api: GitApi):
|
||||
releaseTypeRepo = cls(git_api=git_api)
|
||||
releaseTypeRepo.get_from_git = True
|
||||
return releaseTypeRepo
|
||||
release_type_repo = cls(git_api=git_api)
|
||||
release_type_repo.get_from_git = True
|
||||
return release_type_repo
|
||||
|
||||
@classmethod
|
||||
def from_environment(cls, environment_api: EnvironmentApi):
|
||||
releaseTypeRepo = cls(environment_api=environment_api)
|
||||
releaseTypeRepo.get_from_env = True
|
||||
return releaseTypeRepo
|
||||
release_type_repo = cls(environment_api=environment_api)
|
||||
release_type_repo.get_from_env = True
|
||||
return release_type_repo
|
||||
|
||||
def __get_release_type_git(self) -> ReleaseType | None:
|
||||
latest_commit = self.git_api.get_latest_commit()
|
||||
|
||||
if ReleaseType.MAJOR.name in latest_commit.upper():
|
||||
return ReleaseType.MAJOR
|
||||
elif ReleaseType.MINOR.name in latest_commit.upper():
|
||||
return ReleaseType.MINOR
|
||||
elif ReleaseType.PATCH.name in latest_commit.upper():
|
||||
return ReleaseType.PATCH
|
||||
elif ReleaseType.SNAPSHOT.name in latest_commit.upper():
|
||||
return ReleaseType.SNAPSHOT
|
||||
else:
|
||||
return None
|
||||
match latest_commit.upper():
|
||||
case ReleaseType.MAJOR.name:
|
||||
return ReleaseType.MAJOR
|
||||
case ReleaseType.MINOR.name:
|
||||
return ReleaseType.MINOR
|
||||
case ReleaseType.PATCH.name:
|
||||
return ReleaseType.PATCH
|
||||
case ReleaseType.SNAPSHOT.name:
|
||||
return ReleaseType.SNAPSHOT
|
||||
case _:
|
||||
return None
|
||||
|
||||
def __get_release_type_environment(self) -> ReleaseType | None:
|
||||
release_name = self.environment_api.get(
|
||||
|
@ -86,24 +86,25 @@ class ReleaseTypeRepository:
|
|||
raise ValueError(
|
||||
"Release Name not found. Is the Environment correctly configured?"
|
||||
)
|
||||
elif ReleaseType.MAJOR.name in release_name.upper():
|
||||
return ReleaseType.MAJOR
|
||||
elif ReleaseType.MINOR.name in release_name.upper():
|
||||
return ReleaseType.MINOR
|
||||
elif ReleaseType.PATCH.name in release_name.upper():
|
||||
return ReleaseType.PATCH
|
||||
elif ReleaseType.SNAPSHOT.name in release_name.upper():
|
||||
return ReleaseType.SNAPSHOT
|
||||
else:
|
||||
return None
|
||||
|
||||
match release_name.upper():
|
||||
case ReleaseType.MAJOR.name:
|
||||
return ReleaseType.MAJOR
|
||||
case ReleaseType.MINOR.name:
|
||||
return ReleaseType.MINOR
|
||||
case ReleaseType.PATCH.name:
|
||||
return ReleaseType.PATCH
|
||||
case ReleaseType.SNAPSHOT.name:
|
||||
return ReleaseType.SNAPSHOT
|
||||
case _:
|
||||
return None
|
||||
|
||||
def get_release_type(self) -> ReleaseType | None:
|
||||
if self.get_from_git:
|
||||
return self.__get_release_type_git()
|
||||
elif self.get_from_env:
|
||||
if self.get_from_env:
|
||||
return self.__get_release_type_environment()
|
||||
else:
|
||||
raise ValueError("No valid api passed to ReleaseTypeRepository")
|
||||
raise ValueError("No valid api passed to ReleaseTypeRepository")
|
||||
|
||||
|
||||
class ReleaseContextRepository:
|
||||
|
|
Loading…
Reference in a new issue