@@ -87,7 +87,7 @@ def collect_commit_range_diff_documents(
8787 for diff in diff_index :
8888 commit_documents_to_scan .append (
8989 Document (
90- path = get_path_by_os (get_diff_file_path (diff )),
90+ path = get_path_by_os (get_diff_file_path (diff , repo = repo )),
9191 content = get_diff_file_content (diff ),
9292 is_git_diff_format = True ,
9393 unique_id = commit_id ,
@@ -166,7 +166,7 @@ def get_commit_range_modified_documents(
166166 for diff in modified_files_diff :
167167 progress_bar .update (progress_bar_section )
168168
169- file_path = get_path_by_os (get_diff_file_path (diff ))
169+ file_path = get_path_by_os (get_diff_file_path (diff , repo = repo ))
170170
171171 diff_documents .append (
172172 Document (
@@ -211,16 +211,24 @@ def parse_pre_receive_input() -> str:
211211 return pre_receive_input .splitlines ()[0 ]
212212
213213
214- def get_diff_file_path (diff : 'Diff' , relative : bool = False ) -> Optional [str ]:
214+ def get_diff_file_path (diff : 'Diff' , relative : bool = False , repo : Optional [ 'Repo' ] = None ) -> Optional [str ]:
215215 if relative :
216216 # relative to the repository root
217217 return diff .b_path if diff .b_path else diff .a_path
218218
219+ # Try blob-based paths first (most reliable when available)
219220 if diff .b_blob :
220221 return diff .b_blob .abspath
221222 if diff .a_blob :
222223 return diff .a_blob .abspath
223224
225+ # Fallback: construct an absolute path from a relative path
226+ # This handles renames and other cases where blobs might be None
227+ if repo and repo .working_tree_dir :
228+ target_path = diff .b_path if diff .b_path else diff .a_path
229+ if target_path :
230+ return os .path .abspath (os .path .join (repo .working_tree_dir , target_path ))
231+
224232 return None
225233
226234
@@ -244,7 +252,7 @@ def get_pre_commit_modified_documents(
244252 for diff in diff_index :
245253 progress_bar .update (progress_bar_section )
246254
247- file_path = get_path_by_os (get_diff_file_path (diff ))
255+ file_path = get_path_by_os (get_diff_file_path (diff , repo = repo ))
248256
249257 diff_documents .append (
250258 Document (
0 commit comments