Skip to content

Commit bad6fa8

Browse files
claudespoorcc
authored andcommitted
fix(git): guard against IndexError when chosen equals repo_root
chosen.relative_to(repo_root).parts is empty when the resolved src directory is the repo root itself (e.g. src: .). Extracting parts into a variable and checking it before indexing prevents an IndexError and correctly skips the safe_rm step in that edge case. https://claude.ai/code/session_014ZRQGvyTdWBqoRjtu7gsSC
1 parent 51c517b commit bad6fa8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

dfetch/vcs/git.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,9 @@ def _move_src_folder_up(remote: str, src: str) -> None:
401401
chosen = resolved_dirs[0]
402402
try:
403403
move_directory_contents(str(chosen), ".")
404-
top = repo_root / chosen.relative_to(repo_root).parts[0]
405-
safe_rm(top, within=repo_root)
404+
parts = chosen.relative_to(repo_root).parts
405+
if parts:
406+
safe_rm(repo_root / parts[0], within=repo_root)
406407
except FileNotFoundError:
407408
logger.warning(
408409
f"The 'src:' filter '{chosen}' didn't match any files from '{remote}'"

0 commit comments

Comments
 (0)