Fix logical error

Using match would always produce None results, as we are matching
a string exactly. Reintroducing more fuzzy "in" logic fixed tests.
This commit is contained in:
erik 2023-05-02 13:23:42 +02:00
parent 8fd243a60d
commit e27db86477

View file

@ -63,40 +63,35 @@ class ReleaseTypeRepository:
return release_type_repo
def __get_release_type_git(self) -> ReleaseType | None:
latest_commit = self.git_api.get_latest_commit()
match latest_commit.upper():
case ReleaseType.MAJOR.name:
latest_commit = self.git_api.get_latest_commit().upper()
if ReleaseType.MAJOR.name in latest_commit:
return ReleaseType.MAJOR
case ReleaseType.MINOR.name:
if ReleaseType.MINOR.name in latest_commit:
return ReleaseType.MINOR
case ReleaseType.PATCH.name:
if ReleaseType.PATCH.name in latest_commit:
return ReleaseType.PATCH
case ReleaseType.SNAPSHOT.name:
if ReleaseType.SNAPSHOT.name in latest_commit:
return ReleaseType.SNAPSHOT
case _:
return None
def __get_release_type_environment(self) -> ReleaseType | None:
release_name = self.environment_api.get(
EnvironmentKeys.DDADEVOPS_RELEASE_TYPE.name
)
).upper()
if release_name is None:
raise ValueError(
"Release Name not found. Is the Environment correctly configured?"
)
match release_name.upper():
case ReleaseType.MAJOR.name:
if ReleaseType.MAJOR.name in release_name:
return ReleaseType.MAJOR
case ReleaseType.MINOR.name:
if ReleaseType.MINOR.name in release_name:
return ReleaseType.MINOR
case ReleaseType.PATCH.name:
if ReleaseType.PATCH.name in release_name:
return ReleaseType.PATCH
case ReleaseType.SNAPSHOT.name:
if ReleaseType.SNAPSHOT.name in release_name:
return ReleaseType.SNAPSHOT
case _:
return None
def get_release_type(self) -> ReleaseType | None: