-
Notifications
You must be signed in to change notification settings - Fork 110
Add .comfyignore support to node packaging #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f1f65a0
Enhance packaging with .comfyignore support 📦
HenkDz b105302
Refactor file_utils and add comprehensive tests 🧪
HenkDz 319be7d
Refactor file_utils to fix lint and test erorrs
HenkDz e9a5a49
- Remove colorama dependency from requirements.compiled 🚫
HenkDz ed51466
- Update pack command help text to clarify .comfyignore usage 📦
HenkDz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,3 +61,4 @@ requirements.compiled | |
| override.txt | ||
| .coverage | ||
| coverage.xml | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import os | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from comfy_cli import file_utils | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def restore_cwd(): | ||
| original_cwd = Path.cwd() | ||
| try: | ||
| yield | ||
| finally: | ||
| os.chdir(original_cwd) | ||
|
|
||
|
|
||
| def test_zip_files_respects_comfyignore(tmp_path, monkeypatch): | ||
| project_dir = tmp_path | ||
| (project_dir / "keep.txt").write_text("keep", encoding="utf-8") | ||
| (project_dir / "ignore.log").write_text("ignore", encoding="utf-8") | ||
| ignored_dir = project_dir / "ignored_dir" | ||
| ignored_dir.mkdir() | ||
| (ignored_dir / "nested.txt").write_text("nested", encoding="utf-8") | ||
|
|
||
| (project_dir / ".comfyignore").write_text("*.log\nignored_dir/\n", encoding="utf-8") | ||
|
|
||
| zip_path = project_dir / "node.zip" | ||
|
|
||
| monkeypatch.chdir(project_dir) | ||
| monkeypatch.setattr( | ||
| file_utils, | ||
| "list_git_tracked_files", | ||
| lambda base_path=".": [ | ||
| "keep.txt", | ||
| "ignore.log", | ||
| "ignored_dir/nested.txt", | ||
| ], | ||
| ) | ||
|
|
||
| file_utils.zip_files(str(zip_path)) | ||
|
|
||
| with zipfile.ZipFile(zip_path, "r") as zf: | ||
| names = set(zf.namelist()) | ||
|
|
||
| assert "keep.txt" in names | ||
| assert "ignore.log" not in names | ||
| assert not any(name.startswith("ignored_dir/") for name in names) | ||
|
|
||
|
|
||
| def test_zip_files_force_include_overrides_ignore(tmp_path, monkeypatch): | ||
| project_dir = tmp_path | ||
| include_dir = project_dir / "include_me" | ||
| include_dir.mkdir() | ||
| (include_dir / "data.json").write_text("{}", encoding="utf-8") | ||
|
|
||
| (project_dir / "other.txt").write_text("ok", encoding="utf-8") | ||
| (project_dir / ".comfyignore").write_text("include_me/\n", encoding="utf-8") | ||
|
|
||
| zip_path = project_dir / "node.zip" | ||
|
|
||
| monkeypatch.chdir(project_dir) | ||
| monkeypatch.setattr( | ||
| file_utils, | ||
| "list_git_tracked_files", | ||
| lambda base_path=".": [ | ||
| "other.txt", | ||
| "include_me/data.json", | ||
| ], | ||
| ) | ||
|
|
||
| file_utils.zip_files(str(zip_path), includes=["include_me"]) | ||
|
|
||
| with zipfile.ZipFile(zip_path, "r") as zf: | ||
| names = set(zf.namelist()) | ||
|
|
||
| assert "include_me/data.json" in names | ||
| assert "other.txt" in names | ||
|
|
||
|
|
||
| def test_zip_files_without_git_falls_back_to_walk(tmp_path, monkeypatch): | ||
| project_dir = tmp_path | ||
| (project_dir / "file.txt").write_text("data", encoding="utf-8") | ||
| zip_path = project_dir / "node.zip" | ||
|
|
||
| monkeypatch.chdir(project_dir) | ||
| monkeypatch.setattr(file_utils, "list_git_tracked_files", lambda base_path=".": []) | ||
|
|
||
| file_utils.zip_files(str(zip_path)) | ||
|
|
||
| with zipfile.ZipFile(zip_path, "r") as zf: | ||
| names = set(zf.namelist()) | ||
|
|
||
| assert "file.txt" in names | ||
| assert "node.zip" not in names |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.