Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_content, get_file_dir, join_paths
from cycode.cli.utils.shell_executor import shell
from cycode.cyclient import logger

Expand Down Expand Up @@ -39,6 +39,23 @@ def get_manifest_file_path(self, document: Document) -> str:
else document.path
)

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):
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)

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

@abstractmethod
def is_project(self, document: Document) -> bool:
pass
Expand All @@ -50,11 +67,3 @@ def get_command(self, manifest_file_path: str) -> List[str]:
@abstractmethod
def get_lock_file_name(self) -> str:
pass

def try_restore_dependencies(self, document: Document) -> Optional[Document]:
manifest_file_path = self.get_manifest_file_path(document)
return Document(
build_dep_tree_path(document.path, self.get_lock_file_name()),
execute_command(self.get_command(manifest_file_path), manifest_file_path, self.command_timeout),
self.is_git_diff,
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import List

import click
Expand All @@ -22,3 +23,6 @@ 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:
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:
return 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 Down