fix: update remaining subprocess calls in git.py to use run_command

- Replace subprocess.check_output with run_command in status() and is_git_repo()
- Ensures consistent Windows compatibility across all git operations
- Resolves S607 lint errors for partial executable paths

The B019 lru_cache warning is pre-existing and unrelated to subprocess changes.

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-09-16 17:57:34 +00:00
parent 44ba420130
commit 870955b4e9

View File

@@ -32,20 +32,25 @@ class Repository:
def status(self) -> str:
"""Get the git status in porcelain format."""
return subprocess.check_output(
result = run_command(
["git", "status", "--branch", "--porcelain"],
cwd=self.path,
encoding="utf-8",
).strip()
capture_output=True,
text=True,
check=True,
)
return result.stdout.strip()
@lru_cache(maxsize=None)
def is_git_repo(self) -> bool:
"""Check if the current directory is a git repository."""
try:
subprocess.check_output(
run_command(
["git", "rev-parse", "--is-inside-work-tree"],
cwd=self.path,
encoding="utf-8",
capture_output=True,
text=True,
check=True,
)
return True
except subprocess.CalledProcessError: