fix(git): handle divergent branches safely during pull

- Use --ff-only flag to detect non-fast-forward situations
- Create backup branch before resetting divergent local branch
- Reset to remote branch when fast-forward is not possible
- Use time.strftime() instead of datetime for better compatibility
- Bump version to 3.38.2
This commit is contained in:
Dr.Lt.Data
2025-12-12 12:22:24 +09:00
parent d3a4a7a0fa
commit 891005bcd3
3 changed files with 21 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import subprocess
import sys
import os
import traceback
import time
import git
import json
@@ -219,7 +220,14 @@ def gitpull(path):
repo.close()
return
remote.pull()
try:
repo.git.pull('--ff-only')
except git.GitCommandError:
backup_name = f'backup_{time.strftime("%Y%m%d_%H%M%S")}'
repo.create_head(backup_name)
print(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}")
repo.git.reset('--hard', f'{remote_name}/{branch_name}')
print(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}")
repo.git.submodule('update', '--init', '--recursive')
new_commit_hash = repo.head.commit.hexsha