|
6 | 6 | from pathlib import Path |
7 | 7 | from typing import TYPE_CHECKING, Optional |
8 | 8 |
|
9 | | -import git |
10 | 9 | from pygls import uris |
11 | 10 |
|
12 | 11 | from codeflash.api.cfapi import get_codeflash_api_key, get_user_id |
@@ -155,11 +154,13 @@ def _find_pyproject_toml(workspace_path: str) -> tuple[Path | None, bool]: |
155 | 154 |
|
156 | 155 | # should be called the first thing to initialize and validate the project |
157 | 156 | @server.feature("initProject") |
158 | | -def init_project(server: CodeflashLanguageServer, params: ValidateProjectParams) -> dict[str, str]: # noqa: PLR0911 |
| 157 | +def init_project(server: CodeflashLanguageServer, params: ValidateProjectParams) -> dict[str, str]: |
159 | 158 | from codeflash.cli_cmds.cmd_init import is_valid_pyproject_toml |
160 | 159 |
|
161 | | - pyproject_toml_path: Path | None = getattr(params, "config_file", None) or getattr(server.args, "config_file", None) |
| 160 | + # Always process args in the init project, the extension can call |
| 161 | + server.args_processed_before = False |
162 | 162 |
|
| 163 | + pyproject_toml_path: Path | None = getattr(params, "config_file", None) or getattr(server.args, "config_file", None) |
163 | 164 | if pyproject_toml_path is not None: |
164 | 165 | # if there is a config file provided use it |
165 | 166 | server.prepare_optimizer_arguments(pyproject_toml_path) |
@@ -196,14 +197,6 @@ def init_project(server: CodeflashLanguageServer, params: ValidateProjectParams) |
196 | 197 | return {"status": "error", "message": "not valid", "pyprojectPath": pyproject_toml_path} |
197 | 198 |
|
198 | 199 | args = process_args(server) |
199 | | - repo = git.Repo(args.module_root, search_parent_directories=True) |
200 | | - if repo.bare: |
201 | | - return {"status": "error", "message": "Repository is in bare state"} |
202 | | - |
203 | | - try: |
204 | | - _ = repo.head.commit |
205 | | - except Exception: |
206 | | - return {"status": "error", "message": "Repository has no commits (unborn HEAD)"} |
207 | 200 |
|
208 | 201 | return {"status": "success", "moduleRoot": args.module_root, "pyprojectPath": pyproject_toml_path, "root": root} |
209 | 202 |
|
|
0 commit comments