Skip to content

Commit 0f5c9ef

Browse files
committed
CM-41217 Add absolute path to document
1 parent ba6d274 commit 0f5c9ef

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

cycode/cli/commands/scan/repository/repository_command.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ def repository_command(context: click.Context, path: str, branch: str) -> None:
4848
# FIXME(MarshalX): probably file could be tree or submodule too. we expect blob only
4949
progress_bar.update(ScanProgressBarSection.PREPARE_LOCAL_FILES)
5050

51-
file_path = file.path if monitor else get_path_by_os(os.path.join(path, file.path))
52-
documents_to_scan.append(Document(file_path, file.data_stream.read().decode('UTF-8', errors='replace')))
51+
absolute_path = get_path_by_os(os.path.join(path, file.path))
52+
file_path = file.path if monitor else absolute_path
53+
documents_to_scan.append(
54+
Document(
55+
file_path,
56+
file.data_stream.read().decode('UTF-8', errors='replace'),
57+
absolute_path=absolute_path,
58+
)
59+
)
5360

5461
documents_to_scan = exclude_irrelevant_documents_to_scan(scan_type, documents_to_scan)
5562

cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
2222
return os.path.isfile(restore_file_path)
2323

2424
def get_working_directory(self, document: Document) -> Optional[str]:
25-
return os.path.dirname(document.path)
25+
return os.path.dirname(document.absolute_path)

cycode/cli/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
class Document:
99
def __init__(
10-
self, path: str, content: str, is_git_diff_format: bool = False, unique_id: Optional[str] = None
10+
self,
11+
path: str,
12+
content: str,
13+
is_git_diff_format: bool = False,
14+
unique_id: Optional[str] = None,
15+
absolute_path: Optional[str] = None,
1116
) -> None:
1217
self.path = path
1318
self.content = content
1419
self.is_git_diff_format = is_git_diff_format
1520
self.unique_id = unique_id
21+
self.absolute_path = absolute_path
1622

1723
def __repr__(self) -> str:
1824
return 'path:{0}, content:{1}'.format(self.path, self.content)

0 commit comments

Comments
 (0)