[PR #2719] [MERGED] feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs #2721

Closed
opened 2026-10-28 21:12:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/ComfyUI-Manager/pull/2719
Author: @Kosinkadink
Created: 3/21/2026
Status: ✅ Merged
Merged: 3/26/2026
Merged by: @ltdrdata

Base: manager-v4 ← Head: fix/pygit2-fallback-v4


📝 Commits (3)

  • 8831f1f feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs
  • 73f4dd5 fix(pygit2): address review findings + bump version to 4.2b1
  • c820627 style: fix ruff F841 unused variable and F541 unnecessary f-string

📊 Changes

11 files changed (+2061 additions, -400 deletions)

View changed files

📝 cm_cli/__main__.py (+4 -4)
📝 comfyui_manager/common/context.py (+3 -3)
➕ comfyui_manager/common/git_compat.py (+844 -0)
📝 comfyui_manager/common/git_helper.py (+103 -103)
📝 comfyui_manager/common/timestamp_utils.py (+1 -1)
📝 comfyui_manager/glob/manager_core.py (+263 -276)
📝 comfyui_manager/glob/utils/environment_utils.py (+10 -10)
📝 comfyui_manager/legacy/manager_core.py (+1 -1)
📝 pyproject.toml (+2 -2)
📝 requirements.txt (+1 -0)
➕ tests/test_git_compat.py (+829 -0)

📄 Description

Eliminates the hidden system git requirement for Desktop 2.0 standalone installs by wrapping all git operations behind a git_compat.py abstraction layer that supports both GitPython and pygit2 backends.

How it works

  • When CM_USE_PYGIT2=1 is set (by Desktop 2.0 Launcher via PR #274), or when system git is unavailable, the pygit2 backend is used automatically
  • Falls back gracefully to GitPython if neither pygit2 nor system git is available (preserving pre-existing behavior)
  • All 6 non-legacy files updated with minimal calling-code changes — zero behavioral differences

Files changed

  • comfyui_manager/common/git_compat.py — new wrapper with abstract GitRepo base class, _GitPythonRepo (1:1 pass-throughs), _Pygit2Repo implementation
  • comfyui_manager/glob/manager_core.py — 14 git.Repo usages converted
  • comfyui_manager/common/git_helper.py — 7 git.Repo usages converted (standalone subprocess script)
  • comfyui_manager/common/context.py — get_comfyui_tag() converted
  • comfyui_manager/glob/utils/environment_utils.py — print_comfyui_version() + setup_environment() converted
  • cm_cli/__main__.py — check_comfyui_hash() converted
  • comfyui_manager/common/timestamp_utils.py — repo.heads usage converted
  • tests/test_git_compat.py — 47 tests comparing both backends via subprocess isolation

Additional fixes

  • Resource leaks across all repo-opening call sites (context managers added)
  • get_script_env() propagates CM_USE_PYGIT2 to subprocesses
  • Submodule fallback logs clear message when system git is absent

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/ComfyUI-Manager/pull/2719 **Author:** [@Kosinkadink](https://github.com/Kosinkadink) **Created:** 3/21/2026 **Status:** ✅ Merged **Merged:** 3/26/2026 **Merged by:** [@ltdrdata](https://github.com/ltdrdata) **Base:** `manager-v4` ← **Head:** `fix/pygit2-fallback-v4` --- ### 📝 Commits (3) - [`8831f1f`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/8831f1ffcf515750a76abe9d69bc6a7607e49a4b) feat: add pygit2 compatibility wrapper for standalone Desktop 2.0 installs - [`73f4dd5`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/73f4dd5637e4e5e904bc10dd63040b05fc9f9da5) fix(pygit2): address review findings + bump version to 4.2b1 - [`c820627`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/c820627b06db5ad5e5a3b3ecab766a8bf6623266) style: fix ruff F841 unused variable and F541 unnecessary f-string ### 📊 Changes **11 files changed** (+2061 additions, -400 deletions) <details> <summary>View changed files</summary> 📝 `cm_cli/__main__.py` (+4 -4) 📝 `comfyui_manager/common/context.py` (+3 -3) ➕ `comfyui_manager/common/git_compat.py` (+844 -0) 📝 `comfyui_manager/common/git_helper.py` (+103 -103) 📝 `comfyui_manager/common/timestamp_utils.py` (+1 -1) 📝 `comfyui_manager/glob/manager_core.py` (+263 -276) 📝 `comfyui_manager/glob/utils/environment_utils.py` (+10 -10) 📝 `comfyui_manager/legacy/manager_core.py` (+1 -1) 📝 `pyproject.toml` (+2 -2) 📝 `requirements.txt` (+1 -0) ➕ `tests/test_git_compat.py` (+829 -0) </details> ### 📄 Description Eliminates the hidden system git requirement for Desktop 2.0 standalone installs by wrapping all git operations behind a `git_compat.py` abstraction layer that supports both GitPython and pygit2 backends. ### How it works - When `CM_USE_PYGIT2=1` is set (by Desktop 2.0 Launcher via [PR #274](https://github.com/Comfy-Org/ComfyUI-Desktop-2.0-Beta/pull/274)), or when system git is unavailable, the pygit2 backend is used automatically - Falls back gracefully to GitPython if neither pygit2 nor system git is available (preserving pre-existing behavior) - All 6 non-legacy files updated with minimal calling-code changes — zero behavioral differences ### Files changed - **`comfyui_manager/common/git_compat.py`** — new wrapper with abstract `GitRepo` base class, `_GitPythonRepo` (1:1 pass-throughs), `_Pygit2Repo` implementation - **`comfyui_manager/glob/manager_core.py`** — 14 `git.Repo` usages converted - **`comfyui_manager/common/git_helper.py`** — 7 `git.Repo` usages converted (standalone subprocess script) - **`comfyui_manager/common/context.py`** — `get_comfyui_tag()` converted - **`comfyui_manager/glob/utils/environment_utils.py`** — `print_comfyui_version()` + `setup_environment()` converted - **`cm_cli/__main__.py`** — `check_comfyui_hash()` converted - **`comfyui_manager/common/timestamp_utils.py`** — `repo.heads` usage converted - **`tests/test_git_compat.py`** — 47 tests comparing both backends via subprocess isolation ### Additional fixes - Resource leaks across all repo-opening call sites (context managers added) - `get_script_env()` propagates `CM_USE_PYGIT2` to subprocesses - Submodule fallback logs clear message when system git is absent --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-28 21:12:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/ComfyUI-Manager#2721
No description provided.