Skip to content

Commit a2dae48

Browse files
committed
Fix: Use correct root path when listing files with git (#2087)
1 parent 8bba93b commit a2dae48

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sqlmesh/utils/git.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ def __init__(self, repo: str | Path):
1111
self._work_dir = Path(repo)
1212

1313
def list_untracked_files(self) -> t.List[Path]:
14-
return self._execute_list_output(["ls-files", "--others", "--exclude-standard"])
14+
return self._execute_list_output(
15+
["ls-files", "--others", "--exclude-standard"], self._work_dir
16+
)
1517

1618
def list_changed_files(self, target_branch: str = "main") -> t.List[Path]:
17-
return self._execute_list_output(["diff", "--name-only", "--diff-filter=d", target_branch])
19+
return self._execute_list_output(
20+
["diff", "--name-only", "--diff-filter=d", target_branch], self._git_root
21+
)
1822

19-
def _execute_list_output(self, commands: t.List[str]) -> t.List[Path]:
20-
return [(self._git_root / o).absolute() for o in self._execute(commands).split("\n") if o]
23+
def _execute_list_output(self, commands: t.List[str], base_path: Path) -> t.List[Path]:
24+
return [(base_path / o).absolute() for o in self._execute(commands).split("\n") if o]
2125

2226
def _execute(self, commands: t.List[str]) -> str:
2327
result = subprocess.run(["git"] + commands, cwd=self._work_dir, stdout=subprocess.PIPE)

0 commit comments

Comments
 (0)