@@ -39,10 +39,12 @@ class BoughAnalyzer:
3939
4040 def __init__ (
4141 self ,
42+ repo_root : Path ,
4243 workspace_root : Path ,
4344 config : "BoughConfig" ,
4445 packages : dict [str , Package ] | None = None ,
4546 ) -> None :
47+ self .repo_root = repo_root
4648 self .workspace_root = workspace_root
4749 logger .debug (f"Initializing analyzer for workspace: { workspace_root } " )
4850 self .config = config
@@ -54,10 +56,12 @@ def __init__(
5456 logger .debug (f"Discovered { len (self .packages )} packages" )
5557
5658 @classmethod
57- def from_workspace (cls , workspace_root : Path , config_path : Path ) -> "BoughAnalyzer" :
59+ def from_workspace (
60+ cls , repo_root : Path , workspace_root : Path , config_path : Path
61+ ) -> "BoughAnalyzer" :
5862 """Create analyzer by discovering packages from workspace."""
5963 config = load_config (config_path )
60- return cls (workspace_root , config )
64+ return cls (repo_root , workspace_root , config )
6165
6266 def _discover_packages (self ) -> None :
6367 root_pyproject = self .workspace_root / "pyproject.toml"
@@ -159,8 +163,9 @@ def _find_direct_packages(
159163 changed_files : set [str ],
160164 ) -> set [str ]:
161165 directly_affected = set ()
166+ strip_prefix = self .workspace_root .relative_to (self .repo_root )
162167 for file_path in changed_files :
163- file_path_obj = Path (file_path )
168+ file_path_obj = Path (file_path ). relative_to ( strip_prefix )
164169
165170 if self ._matches_patterns (file_path , self .config .ignore ):
166171 logger .debug (f"Ignoring file { file_path } (matches ignore patterns)" )
@@ -210,7 +215,7 @@ def find_affected(
210215 """Return the affected packages and files."""
211216 logger .debug (f"Analyzing changes from { base_commit } to HEAD" )
212217
213- files = find_changed_files (self .workspace_root , base_commit )
218+ files = find_changed_files (self .repo_root , base_commit )
214219 all_affected = self ._find_transitive_packages (self ._find_direct_packages (files ))
215220
216221 if selection != "buildable" :
0 commit comments