ComfyUI-Manager/comfyui_manager/common
Jedrzej Kosinski 49e205acd4
Some checks failed
Publish to PyPI / build-and-publish (push) Has been cancelled
Python Linting / Run Ruff (push) Has been cancelled
feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs (#2719)
* feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs

Add git_compat.py abstraction layer that wraps both GitPython and pygit2
behind a unified GitRepo interface. When CM_USE_PYGIT2=1 is set (by the
Desktop 2.0 Launcher for standalone installs), or when system git is not
available, the pygit2 backend is used automatically.

Key changes:
- New comfyui_manager/common/git_compat.py with abstract GitRepo base class,
  _GitPythonRepo (1:1 pass-throughs) and _Pygit2Repo implementations
- All 6 non-legacy files updated to use the wrapper:
  - comfyui_manager/glob/manager_core.py (14 git.Repo usages)
  - comfyui_manager/common/git_helper.py (7 git.Repo usages)
  - comfyui_manager/common/context.py (1 usage)
  - comfyui_manager/glob/utils/environment_utils.py (2 usages)
  - cm_cli/__main__.py (1 usage)
  - comfyui_manager/common/timestamp_utils.py (repo.heads usage)
- get_script_env() propagates CM_USE_PYGIT2 to subprocesses
- git_helper.py uses sys.path.insert to find git_compat as standalone script
- All repo handles wrapped in context managers to prevent resource leaks
- get_head_by_name returns _HeadProxy for interface consistency
- Submodule fallback logs clear message when system git is absent
- 47 tests comparing both backends via subprocess isolation

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d0ec5-cb9f-74df-a1a2-0c8154a330b3

* fix(pygit2): address review findings + bump version to 4.2b1

- C1: add submodule_update() after pygit2 clone for recursive parity
- C2: check subprocess returncode in submodule_update fallback
- C3: move GIT_OPT_SET_OWNER_VALIDATION to module-level (once at import)
- H1: use context manager in git_pull() to prevent resource leaks
- Bump version to 4.2b1, version_code to [4, 2]
- Add pygit2 to dev dependencies and requirements.txt

* style: fix ruff F841 unused variable and F541 unnecessary f-string

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Dr.Lt.Data <dr.lt.data@gmail.com>
2026-03-27 08:42:26 +09:00
..
__init__.py fix(git): handle divergent branches safely + datetime fallback 2025-12-12 22:45:05 +09:00
cm_global.py restructuring 2025-04-13 09:26:02 +09:00
cnr_utils.py refactor(core): add verbose config, improve module lookup, fix is_valid_url 2025-12-27 03:57:19 +09:00
context.py feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs (#2719) 2026-03-27 08:42:26 +09:00
enums.py modified: security policy 2025-06-27 01:38:38 +09:00
git_compat.py feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs (#2719) 2026-03-27 08:42:26 +09:00
git_helper.py feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs (#2719) 2026-03-27 08:42:26 +09:00
git_utils.py fix(api): improve import_fail_info_bulk lookup for cnr_id and aux_id 2025-12-15 02:54:30 +09:00
manager_downloader.py Merge branch 'main' into draft-v4 2025-07-24 12:41:48 +09:00
manager_security.py security(api): add path traversal and CRLF injection protection 2026-01-08 18:35:03 +09:00
manager_util.py feat(deps): add unified dependency resolver using uv pip compile (#2589) 2026-03-07 06:51:53 +09:00
node_package.py restructuring 2025-04-13 09:26:02 +09:00
README.md Merge branch 'main' into draft-v4 2025-06-01 06:23:11 +09:00
security_check.py fix(security): add litellm supply chain attack detection (PYSEC-2026-2) (#2732) 2026-03-26 04:17:50 +09:00
timestamp_utils.py feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs (#2719) 2026-03-27 08:42:26 +09:00
unified_dep_resolver.py feat(cli): expand --uv-compile to all node management commands with conflict attribution (#2682) 2026-03-14 07:58:29 +09:00

ComfyUI-Manager: Core Backend (glob)

This directory contains the Python backend modules that power ComfyUI-Manager, handling the core functionality of node management, downloading, security, and server operations.

Core Modules

  • manager_downloader.py: Handles downloading operations for models, extensions, and other resources.
  • manager_util.py: Provides utility functions used throughout the system.

Specialized Modules

  • cm_global.py: Maintains global variables and state management across the system.
  • cnr_utils.py: Helper utilities for interacting with the custom node registry (CNR).
  • git_utils.py: Git-specific utilities for repository operations.
  • node_package.py: Handles the packaging and installation of node extensions.
  • security_check.py: Implements the multi-level security system for installation safety.