Skip to content

Commit

Permalink
fix: Use pythonic error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpelsepp committed Dec 19, 2024
1 parent 5d1d222 commit 1b0191e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/gallia/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: Apache-2.0

import os
import shutil
import subprocess
import tomllib
from pathlib import Path
Expand All @@ -29,13 +28,14 @@ def get_value(self, key: str, default: Any | None = None) -> Any | None:


def get_git_root() -> Path | None:
git_path = shutil.which("git")
if git_path is None:
return None
try:
p = subprocess.run(
[git_path, "rev-parse", "--show-toplevel"], capture_output=True, check=True
["git", "rev-parse", "--show-toplevel"],
capture_output=True,
check=True,
)
except FileNotFoundError:
return None
except subprocess.CalledProcessError:
return None
return Path(p.stdout.decode().strip())
Expand Down

0 comments on commit 1b0191e

Please sign in to comment.