mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-25 16:18:13 +00:00
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:
@@ -32,20 +32,25 @@ class Repository:
|
|||||||
|
|
||||||
def status(self) -> str:
|
def status(self) -> str:
|
||||||
"""Get the git status in porcelain format."""
|
"""Get the git status in porcelain format."""
|
||||||
return subprocess.check_output(
|
result = run_command(
|
||||||
["git", "status", "--branch", "--porcelain"],
|
["git", "status", "--branch", "--porcelain"],
|
||||||
cwd=self.path,
|
cwd=self.path,
|
||||||
encoding="utf-8",
|
capture_output=True,
|
||||||
).strip()
|
text=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
return result.stdout.strip()
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def is_git_repo(self) -> bool:
|
def is_git_repo(self) -> bool:
|
||||||
"""Check if the current directory is a git repository."""
|
"""Check if the current directory is a git repository."""
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(
|
run_command(
|
||||||
["git", "rev-parse", "--is-inside-work-tree"],
|
["git", "rev-parse", "--is-inside-work-tree"],
|
||||||
cwd=self.path,
|
cwd=self.path,
|
||||||
encoding="utf-8",
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
|||||||
Reference in New Issue
Block a user