update
This commit is contained in:
4 files changed
+16
-5
No files matched your search
@@ -14,7 +14,7 @@ from collections import defaultdict
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
from devgen.utils import run_git_command
|
from devgen.utils import get_git_root, run_git_command
|
||||||
|
|
||||||
|
|
||||||
# Lock files and other metadata blobs whose full diff would just bloat the
|
# Lock files and other metadata blobs whose full diff would just bloat the
|
||||||
@@ -54,7 +54,7 @@ class DiffBuilder:
|
|||||||
logger=None,
|
logger=None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.max_size = max_size
|
self.max_size = max_size
|
||||||
self.cwd = cwd
|
self.cwd = cwd or get_git_root()
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
def build(self, files: List[str]) -> str:
|
def build(self, files: List[str]) -> str:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from devgen.utils import configure_logger, run_git_command
|
from devgen.utils import configure_logger, get_git_root, run_git_command
|
||||||
|
|
||||||
|
|
||||||
class GitError(RuntimeError):
|
class GitError(RuntimeError):
|
||||||
@@ -26,7 +26,7 @@ class GitOperator:
|
|||||||
logger=None,
|
logger=None,
|
||||||
quiet_commands: bool = True,
|
quiet_commands: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.cwd = cwd
|
self.cwd = cwd or get_git_root()
|
||||||
self.logger = logger or configure_logger("devgen.git")
|
self.logger = logger or configure_logger("devgen.git")
|
||||||
self.quiet_commands = quiet_commands
|
self.quiet_commands = quiet_commands
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ class HuggingfaceProvider(BaseProvider):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(api_url, headers=headers, json=payload, timeout=120)
|
response = requests.post(
|
||||||
|
api_url, headers=headers, json=payload, timeout=120
|
||||||
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
result = response.json()
|
result = response.json()
|
||||||
except requests.HTTPError as e:
|
except requests.HTTPError as e:
|
||||||
|
|||||||
@@ -142,6 +142,15 @@ def configure_logger(
|
|||||||
return logger
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_root(cwd: Optional[Path] = None) -> Optional[Path]:
|
||||||
|
"""Return the root directory of the current git repository, or None."""
|
||||||
|
try:
|
||||||
|
output = run_git_command(["git", "rev-parse", "--show-toplevel"], cwd=cwd)
|
||||||
|
return Path(output) if output else None
|
||||||
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def run_git_command(
|
def run_git_command(
|
||||||
args: list[str],
|
args: list[str],
|
||||||
check: bool = True,
|
check: bool = True,
|
||||||
|
|||||||
Reference in new issue
Block a user