diff --git a/zhenxun/builtin_plugins/web_ui/api/configure/__init__.py b/zhenxun/builtin_plugins/web_ui/api/configure/__init__.py index d969d70f..779653b1 100644 --- a/zhenxun/builtin_plugins/web_ui/api/configure/__init__.py +++ b/zhenxun/builtin_plugins/web_ui/api/configure/__init__.py @@ -40,7 +40,7 @@ async def _(setting: Setting) -> Result: return Result.fail("配置已存在,请先删除DB_URL内容和前端密码再进行设置。") env_file = Path() / ".env.example" if not env_file.exists(): - return Result.fail("配置文件.env.dev不存在。") + return Result.fail("基础配置文件.env.example不存在。") env_text = env_file.read_text(encoding="utf-8") to_env_file = Path() / ".env.dev" if setting.db_url: diff --git a/zhenxun/utils/repo_utils/base_manager.py b/zhenxun/utils/repo_utils/base_manager.py index c25f3ea6..00100399 100644 --- a/zhenxun/utils/repo_utils/base_manager.py +++ b/zhenxun/utils/repo_utils/base_manager.py @@ -287,14 +287,36 @@ class BaseRepoManager(ABC): "rev-parse --is-inside-work-tree", cwd=local_path ) if not success: - return RepoUpdateResult( - repo_type=repo_type or RepoType.GITHUB, - repo_name=repo_name, - owner=owner or "", - old_version="", - new_version="", - error_message=f"{local_path} 不是一个Git仓库", + # 如果不是Git仓库,尝试初始化它 + logger.info(f"目录 {local_path} 不是Git仓库,尝试初始化", LOG_COMMAND) + init_success, _, init_stderr = await run_git_command( + "init", cwd=local_path ) + if not init_success: + return RepoUpdateResult( + repo_type=repo_type or RepoType.GITHUB, + repo_name=repo_name, + owner=owner or "", + old_version="", + new_version="", + error_message=f"初始化Git仓库失败: {init_stderr}", + ) + + # 添加远程仓库 + remote_success, _, remote_stderr = await run_git_command( + f"remote add origin {repo_url}", cwd=local_path + ) + if not remote_success: + return RepoUpdateResult( + repo_type=repo_type or RepoType.GITHUB, + repo_name=repo_name, + owner=owner or "", + old_version="", + new_version="", + error_message=f"添加远程仓库失败: {remote_stderr}", + ) + + logger.info(f"成功初始化Git仓库 {local_path}", LOG_COMMAND) # 获取当前提交ID作为旧版本 success, old_version, _ = await run_git_command(