fix(RepoManager): check if git dir exists

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2023-12-29 18:51:23 +01:00
parent 9a657daffd
commit cda6d31a7c

View File

@@ -69,6 +69,9 @@ class RepoManager:
:param repo: repository to extract the values from :param repo: repository to extract the values from
:return: String in form of "<orga>/<name>" :return: String in form of "<orga>/<name>"
""" """
if not repo.exists() and not repo.joinpath(".git").exists():
return "-"
try: try:
cmd = ["git", "-C", repo, "config", "--get", "remote.origin.url"] cmd = ["git", "-C", repo, "config", "--get", "remote.origin.url"]
result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL) result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
@@ -78,7 +81,7 @@ class RepoManager:
@staticmethod @staticmethod
def get_local_commit(repo: Path) -> str: def get_local_commit(repo: Path) -> str:
if not repo.exists() and repo.joinpath(".git").exists(): if not repo.exists() and not repo.joinpath(".git").exists():
return "-" return "-"
try: try:
@@ -89,7 +92,7 @@ class RepoManager:
@staticmethod @staticmethod
def get_remote_commit(repo: Path) -> str: def get_remote_commit(repo: Path) -> str:
if not repo.exists() and repo.joinpath(".git").exists(): if not repo.exists() and not repo.joinpath(".git").exists():
return "-" return "-"
try: try: