25 lines
725 B
Python
25 lines
725 B
Python
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def git_status(repo_path: str) -> list[str]:
|
|
working_folder: Path = Path(repo_path)
|
|
if not working_folder.exists():
|
|
raise FileExistsError("Folder is not exist")
|
|
|
|
try:
|
|
process: subprocess.CompletedProcess[str] = subprocess.run(
|
|
["git", "-C", f"{working_folder.absolute()}", "status", "--short"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
|
|
changes: list[str] = [
|
|
line.strip() for line in process.stdout.strip().split("\n")
|
|
]
|
|
|
|
return changes
|
|
|
|
except subprocess.CalledProcessError:
|
|
raise RuntimeError(f"Folder {repo_path} is not a git repository")
|