Skip to content

Commit 10fb6fd

Browse files
committed
CM-31147 [cycode-cli] gradle - poc with TrustPilot using with private repository and should support reading existing restore file from folder
1 parent ce59060 commit 10fb6fd

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

cycode/cli/files_collector/sca/maven/base_restore_maven_dependencies.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import click
55

66
from cycode.cli.models import Document
7-
from cycode.cli.utils.path_utils import get_file_dir, join_paths
7+
from cycode.cli.utils.path_utils import get_file_dir, join_paths, get_file_content
88
from cycode.cli.utils.shell_executor import shell
99
from cycode.cyclient import logger
1010

@@ -43,17 +43,17 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
4343
manifest_file_path = self.get_manifest_file_path(document)
4444
restore_file_path = build_dep_tree_path(document.path, self.get_lock_file_name())
4545

46-
if self._verify_restore_file_already_exist(restore_file_path):
47-
with open(restore_file_path) as file:
48-
restore_file_content = file.read()
46+
if self.verify_restore_file_already_exist(restore_file_path):
47+
restore_file_content = get_file_content(restore_file_path)
4948
else:
5049
restore_file_content = execute_command(self.get_command(manifest_file_path), manifest_file_path,
5150
self.command_timeout)
5251

5352
return Document(restore_file_path, restore_file_content, self.is_git_diff)
5453

55-
def _verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
56-
return False
54+
@abstractmethod
55+
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
56+
pass
5757

5858
@abstractmethod
5959
def is_project(self, document: Document) -> bool:

cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ def get_command(self, manifest_file_path: str) -> List[str]:
2424
def get_lock_file_name(self) -> str:
2525
return BUILD_GRADLE_DEP_TREE_FILE_NAME
2626

27-
def _verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
27+
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
2828
return os.path.isfile(restore_file_path)

cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def get_command(self, manifest_file_path: str) -> List[str]:
2929
def get_lock_file_name(self) -> str:
3030
return join_paths('target', MAVEN_CYCLONE_DEP_TREE_FILE_NAME)
3131

32+
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
33+
False
34+
3235
def try_restore_dependencies(self, document: Document) -> Optional[Document]:
3336
restore_dependencies_document = super().try_restore_dependencies(document)
3437
manifest_file_path = self.get_manifest_file_path(document)
@@ -44,7 +47,7 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
4447
return restore_dependencies_document
4548

4649
def restore_from_secondary_command(
47-
self, document: Document, manifest_file_path: str, restore_dependencies_document: Optional[Document]
50+
self, document: Document, manifest_file_path: str, restore_dependencies_document: Optional[Document]
4851
) -> Optional[Document]:
4952
# TODO(MarshalX): does it even work? Ignored restore_dependencies_document arg
5053
secondary_restore_command = create_secondary_restore_command(manifest_file_path)

0 commit comments

Comments
 (0)