From ead774f6594aac5a7669eb7a2f6b12f716645e0c Mon Sep 17 00:00:00 2001 From: Matt O'Tousa Date: Tue, 10 Sep 2024 01:24:51 -0700 Subject: [PATCH 1/3] Move .plugged to addons/gd-plug/.plugged --- README.md | 1 - addons/gd-plug/plug.gd | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28598d0..b9341b5 100644 --- a/README.md +++ b/README.md @@ -255,7 +255,6 @@ func _on_plugin_updated(plugin): ## Known Limitations -- Godot always show errors from plugin repositories in `./plugged` even with `.gdignore` (See [#32](https://github.com/imjp94/gd-plug/issues/32)) - Sometimes random .import files will be unable to remove, while the reason behind it still remains unknown. - Workaround: Read output for those .import files that failed to remove, and manually delete them. - `autoload` script references in project setting are not cleared as plugin uninstalled. diff --git a/addons/gd-plug/plug.gd b/addons/gd-plug/plug.gd index 8b20175..10f3c09 100644 --- a/addons/gd-plug/plug.gd +++ b/addons/gd-plug/plug.gd @@ -5,7 +5,7 @@ signal updated(plugin) const VERSION = "0.2.6" const DEFAULT_PLUGIN_URL = "https://git::@github.com/%s.git" -const DEFAULT_PLUG_DIR = "res://.plugged" +const DEFAULT_PLUG_DIR = "res://addons/gd-plug/.plugged" const DEFAULT_CONFIG_PATH = DEFAULT_PLUG_DIR + "/index.cfg" const DEFAULT_USER_PLUG_SCRIPT_PATH = "res://plug.gd" const DEFAULT_BASE_PLUG_SCRIPT_PATH = "res://addons/gd-plug/plug.gd" @@ -575,7 +575,7 @@ func remove_installed_plugin(plugin_name): _mutex.unlock() return result -func directory_copy_recursively(from, to, args={}): +func directory_copy_recursively(from, to, args={}, from_root = from): var include = args.get("include", []) var exclude = args.get("exclude", []) var test = args.get("test", false) @@ -589,15 +589,16 @@ func directory_copy_recursively(from, to, args={}): while not file_name.is_empty(): var source = dir.get_current_dir() + ("/" if dir.get_current_dir() != "res://" else "") + file_name var dest = to + ("/" if to != "res://" else "") + file_name + var include_test_source = source.erase(0, from_root.length()) if dir.current_is_dir(): - dest_files += directory_copy_recursively(source, dest, args) + dest_files += directory_copy_recursively(source, dest, args, from_root) else: for include_key in include: - if include_key in source: + if include_key in include_test_source: var is_excluded = false for exclude_key in exclude: - if exclude_key in source: + if exclude_key in include_test_source: is_excluded = true break if not is_excluded: From 34c6e2310d8d51a00552c94e5c94edb2a4810138 Mon Sep 17 00:00:00 2001 From: Matt O'Tousa Date: Wed, 11 Sep 2024 13:14:36 -0700 Subject: [PATCH 2/3] Revert plug directory to res://.plugged Changing the intent of this PR to only *support* .plugged within the addons folder, instead of actually changing the defaults --- README.md | 2 ++ addons/gd-plug/plug.gd | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9341b5..9276078 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,8 @@ func _on_plugin_updated(plugin): ## Known Limitations +- Godot always show errors from plugin repositories in `./plugged` even with `.gdignore` (See [#32](https://github.com/imjp94/gd-plug/issues/32)) + - This can be worked around by placing the `.plugged` folder within `addons`, e.g. `addons/gd-plug/.plugged` - Sometimes random .import files will be unable to remove, while the reason behind it still remains unknown. - Workaround: Read output for those .import files that failed to remove, and manually delete them. - `autoload` script references in project setting are not cleared as plugin uninstalled. diff --git a/addons/gd-plug/plug.gd b/addons/gd-plug/plug.gd index 10f3c09..f170adb 100644 --- a/addons/gd-plug/plug.gd +++ b/addons/gd-plug/plug.gd @@ -5,7 +5,7 @@ signal updated(plugin) const VERSION = "0.2.6" const DEFAULT_PLUGIN_URL = "https://git::@github.com/%s.git" -const DEFAULT_PLUG_DIR = "res://addons/gd-plug/.plugged" +const DEFAULT_PLUG_DIR = "res://.plugged" const DEFAULT_CONFIG_PATH = DEFAULT_PLUG_DIR + "/index.cfg" const DEFAULT_USER_PLUG_SCRIPT_PATH = "res://plug.gd" const DEFAULT_BASE_PLUG_SCRIPT_PATH = "res://addons/gd-plug/plug.gd" From 4d5b6a0e782a48a99b857a22ad894f52afd1c9e0 Mon Sep 17 00:00:00 2001 From: Matt O'Tousa Date: Thu, 12 Sep 2024 16:28:43 -0700 Subject: [PATCH 3/3] root plugin directory include ("res://*"), quit recursing excluded path immediately --- addons/gd-plug/plug.gd | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/addons/gd-plug/plug.gd b/addons/gd-plug/plug.gd index f170adb..8adb7a0 100644 --- a/addons/gd-plug/plug.gd +++ b/addons/gd-plug/plug.gd @@ -591,25 +591,19 @@ func directory_copy_recursively(from, to, args={}, from_root = from): var dest = to + ("/" if to != "res://" else "") + file_name var include_test_source = source.erase(0, from_root.length()) - if dir.current_is_dir(): - dest_files += directory_copy_recursively(source, dest, args, from_root) - else: - for include_key in include: - if include_key in include_test_source: - var is_excluded = false - for exclude_key in exclude: - if exclude_key in include_test_source: - is_excluded = true - break - if not is_excluded: - if test: - if not silent_test: logger.warn("[TEST] Writing to %s" % dest) - else: - dir.make_dir_recursive(to) - if dir.copy(source, dest) == OK: - logger.debug("Copy from %s to %s" % [source, dest]) - dest_files.append(dest) - break + if !_test_path_includes_any_key(exclude, include_test_source): + if dir.current_is_dir(): + dest_files += directory_copy_recursively(source, dest, args, from_root) + else: + if _test_path_includes_any_key(include, include_test_source): + if test: + if !silent_test: + logger.warn("[TEST] Writing to %s" % dest) + else: + dir.make_dir_recursive(to) + if dir.copy(source, dest) == OK: + logger.debug("Copy from %s to %s" % [source, dest]) + dest_files.append(dest) file_name = dir.get_next() dir.list_dir_end() else: @@ -617,6 +611,18 @@ func directory_copy_recursively(from, to, args={}, from_root = from): return dest_files +func _test_path_includes_any_key(keys, path): + for key in keys: + if key.begins_with("res://"): + key = key.erase(0, "res:/".length()) + if path.begins_with(key): + return true + continue + + if key in path: + return true + return false + func directory_delete_recursively(dir_path, args={}): var remove_empty_directory = args.get("remove_empty_directory", true) var exclude = args.get("exclude", [])