diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index f68c27b2d..3233f6948 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -799,7 +799,9 @@ def get_patch_fn(self, module_name, repo_url, install_dir): ) return Path(path) if path is not None else None - def try_apply_patch_reverse(self, module, repo_name, patch_relpath, module_dir): + def try_apply_patch_reverse( + self, module: str, repo_name: str, patch_relpath: Union[Path, str], module_dir: Union[Path, str] + ) -> Path: """ Try reverse applying a patch file to the modified module files @@ -823,11 +825,12 @@ def try_apply_patch_reverse(self, module, repo_name, patch_relpath, module_dir): except LookupError as e: raise LookupError(f"Failed to apply patch in reverse for module '{module_fullname}' due to: {e}") - # Write the patched files to a temporary directory + # Write the patched files and rest of the files to a temporary directory log.debug("Writing patched files to tmpdir") temp_dir = Path(tempfile.mkdtemp()) temp_module_dir = temp_dir / module temp_module_dir.mkdir(parents=True, exist_ok=True) + for file, new_content in new_files.items(): fn = temp_module_dir / file with open(fn, "w") as fh: diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index 5c31e9691..23966be13 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -314,15 +314,19 @@ def component_files_identical(self, component_name, base_path, commit, component self.checkout_branch() else: self.checkout(commit) - component_files = ["main.nf", "meta.yml"] - files_identical = {file: True for file in component_files} + files_identical = {} component_dir = self.get_component_dir(component_name, component_type) + component_files = [file.relative_to(component_dir) for file in Path(component_dir).rglob("*") if file.is_file()] for file in component_files: - try: - files_identical[file] = filecmp.cmp(os.path.join(component_dir, file), os.path.join(base_path, file)) - except FileNotFoundError: - log.debug(f"Could not open file: {os.path.join(component_dir, file)}") + component_file = component_dir / file + base_file = base_path / file + if not base_file.exists(): + files_identical[file] = False continue + try: + files_identical[file] = filecmp.cmp(component_file, base_file) + except FileNotFoundError as e: + raise UserWarning(f"Could not open file: {e.filename}") self.checkout_branch() return files_identical