Skip to content

Commit

Permalink
CM-31147 [cycode-cli] gradle - poc with TrustPilot using with private…
Browse files Browse the repository at this point in the history
… repository and should support reading existing restore file from folder
  • Loading branch information
morsa4406 committed Jan 10, 2024
1 parent ce59060 commit 10fb6fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from cycode.cli.models import Document
from cycode.cli.utils.path_utils import get_file_dir, join_paths
from cycode.cli.utils.path_utils import get_file_dir, join_paths, get_file_content
from cycode.cli.utils.shell_executor import shell
from cycode.cyclient import logger

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

if self._verify_restore_file_already_exist(restore_file_path):
with open(restore_file_path) as file:
restore_file_content = file.read()
if self.verify_restore_file_already_exist(restore_file_path):
restore_file_content = get_file_content(restore_file_path)
else:
restore_file_content = execute_command(self.get_command(manifest_file_path), manifest_file_path,
self.command_timeout)

return Document(restore_file_path, restore_file_content, self.is_git_diff)

def _verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
return False
@abstractmethod
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
pass

@abstractmethod
def is_project(self, document: Document) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ def get_command(self, manifest_file_path: str) -> List[str]:
def get_lock_file_name(self) -> str:
return BUILD_GRADLE_DEP_TREE_FILE_NAME

def _verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
return os.path.isfile(restore_file_path)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def get_command(self, manifest_file_path: str) -> List[str]:
def get_lock_file_name(self) -> str:
return join_paths('target', MAVEN_CYCLONE_DEP_TREE_FILE_NAME)

def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
False

def try_restore_dependencies(self, document: Document) -> Optional[Document]:
restore_dependencies_document = super().try_restore_dependencies(document)
manifest_file_path = self.get_manifest_file_path(document)
Expand All @@ -44,7 +47,7 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
return restore_dependencies_document

def restore_from_secondary_command(
self, document: Document, manifest_file_path: str, restore_dependencies_document: Optional[Document]
self, document: Document, manifest_file_path: str, restore_dependencies_document: Optional[Document]
) -> Optional[Document]:
# TODO(MarshalX): does it even work? Ignored restore_dependencies_document arg
secondary_restore_command = create_secondary_restore_command(manifest_file_path)
Expand Down

0 comments on commit 10fb6fd

Please sign in to comment.