@@ -30,34 +30,36 @@ def get_lock_file_name(self) -> str:
3030 return join_paths ('target' , MAVEN_CYCLONE_DEP_TREE_FILE_NAME )
3131
3232 def try_restore_dependencies (self , document : Document ) -> Optional [Document ]:
33- restore_dependencies_document = super ().try_restore_dependencies (document )
3433 manifest_file_path = self .get_manifest_file_path (document )
3534 if document .content is None :
36- restore_dependencies_document = self .restore_from_secondary_command (
37- document , manifest_file_path , restore_dependencies_document
38- )
39- else :
40- restore_dependencies_document .content = get_file_content (
41- join_paths (get_file_dir (manifest_file_path ), self .get_lock_file_name ())
42- )
35+ return self .restore_from_secondary_command (document , manifest_file_path )
36+
37+ restore_dependencies_document = super ().try_restore_dependencies (document )
38+ if restore_dependencies_document is None :
39+ return None
40+
41+ restore_dependencies_document .content = get_file_content (
42+ join_paths (get_file_dir (manifest_file_path ), self .get_lock_file_name ())
43+ )
4344
4445 return restore_dependencies_document
4546
46- def restore_from_secondary_command (
47- self , document : Document , manifest_file_path : str , restore_dependencies_document : Optional [Document ]
48- ) -> Optional [Document ]:
49- # TODO(MarshalX): does it even work? Ignored restore_dependencies_document arg
50- secondary_restore_command = create_secondary_restore_commands (manifest_file_path )
51- backup_restore_content = execute_commands (secondary_restore_command , self .command_timeout )
52- restore_dependencies_document = Document (
53- build_dep_tree_path (document .path , MAVEN_DEP_TREE_FILE_NAME ), backup_restore_content , self .is_git_diff
47+ def restore_from_secondary_command (self , document : Document , manifest_file_path : str ) -> Optional [Document ]:
48+ restore_content = execute_commands (
49+ commands = create_secondary_restore_commands (manifest_file_path ),
50+ timeout = self .command_timeout ,
51+ working_directory = self .get_working_directory (document ),
5452 )
55- restore_dependencies = None
56- if restore_dependencies_document .content is not None :
57- restore_dependencies = restore_dependencies_document
58- restore_dependencies .content = get_file_content (MAVEN_DEP_TREE_FILE_NAME )
53+ if restore_content is None :
54+ return None
5955
60- return restore_dependencies
56+ restore_file_path = build_dep_tree_path (document .absolute_path , MAVEN_DEP_TREE_FILE_NAME )
57+ return Document (
58+ path = build_dep_tree_path (document .path , MAVEN_DEP_TREE_FILE_NAME ),
59+ content = get_file_content (restore_file_path ),
60+ is_git_diff_format = self .is_git_diff ,
61+ absolute_path = restore_file_path ,
62+ )
6163
6264
6365def create_secondary_restore_commands (manifest_file_path : str ) -> list [list [str ]]:
0 commit comments