Skip to content

Commit a7d682f

Browse files
committed
fix git configure
1 parent 0c3aef2 commit a7d682f

File tree

1 file changed

+10
-2
lines changed
  • servers/fai-lambda/shared/utils

1 file changed

+10
-2
lines changed

servers/fai-lambda/shared/utils/git.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def clone_repo(repository: str, session_id: str, session_type: str = "session")
6161
shutil.rmtree(session_path)
6262
shutil.copytree(cache_path, session_path)
6363

64+
configure_git_auth(str(session_path))
65+
6466
subprocess.run(
6567
["git", "fetch", "origin"],
6668
cwd=str(session_path),
@@ -81,9 +83,11 @@ def clone_repo(repository: str, session_id: str, session_type: str = "session")
8183
if session_path.exists():
8284
shutil.rmtree(session_path)
8385
_clone_fresh(clone_url, session_path, repository)
86+
configure_git_auth(str(session_path))
8487
else:
8588
logger.info(f"No cache found, cloning fresh into {session_path}")
8689
_clone_fresh(clone_url, session_path, repository)
90+
configure_git_auth(str(session_path))
8791

8892
try:
8993
if cache_path.exists():
@@ -93,8 +97,6 @@ def clone_repo(repository: str, session_id: str, session_type: str = "session")
9397
except Exception as e:
9498
logger.warning(f"Failed to create cache: {e}, continuing without cache")
9599

96-
configure_git_auth(str(session_path))
97-
98100
return str(session_path)
99101

100102

@@ -115,6 +117,12 @@ def _clone_fresh(clone_url: str, repo_path: Path, repository: str) -> None:
115117

116118
def configure_git_auth(repo_path: str) -> None:
117119
"""Configure git user for the repository."""
120+
repo_path_obj = Path(repo_path)
121+
if not repo_path_obj.exists():
122+
raise RuntimeError(f"Repository path does not exist: {repo_path}")
123+
if not (repo_path_obj / ".git").exists():
124+
raise RuntimeError(f"Not a git repository (missing .git directory): {repo_path}")
125+
118126
subprocess.run(["git", "config", "user.name", "fern-support"], cwd=repo_path, check=True)
119127
subprocess.run(["git", "config", "user.email", "[email protected]"], cwd=repo_path, check=True)
120128

0 commit comments

Comments
 (0)