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 9fcd4ca commit ce59060
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ 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):
with open(restore_file_path) as file:
restore_file_content = file.read()
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 is_project(self, document: Document) -> bool:
pass
Expand All @@ -50,11 +66,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)

0 comments on commit ce59060

Please sign in to comment.