Skip to content

Commit d4e0cfc

Browse files
authored
Merge branch 'develop' into eagarwal-cg-10796-lsp-progress-reporting-support
2 parents 725271b + 34990c8 commit d4e0cfc

File tree

7 files changed

+27
-50
lines changed

7 files changed

+27
-50
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
matrix:
3434
os: [
3535
ubuntu-latest,
36-
ubuntu-24.04-arm, # https://github.com/actions/partner-runner-images/issues/37
36+
ubuntu-22.04-arm, # https://github.com/actions/partner-runner-images/issues/37 https://github.com/orgs/community/discussions/148648#discussioncomment-12099554
3737
macos-latest,
3838
macos-14-large
3939
]

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ repos:
7575
entry: bash -c "uv run --frozen --all-extras --dev deptry src --ignore DEP001 --extend-exclude 'codegen-examples/.*'"
7676

7777
- repo: https://github.com/renovatebot/pre-commit-hooks
78-
rev: 39.169.1
78+
rev: 39.169.2
7979
hooks:
8080
- id: renovate-config-validator
8181
- repo: https://github.com/astral-sh/uv-pre-commit
82-
rev: "0.5.30"
82+
rev: "0.5.31"
8383
hooks:
8484
- id: uv-sync
8585
args: ["--frozen", "--all-packages", "--all-extras"]
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
# TEST
2-
# TEST
3-
# TEST
4-
# TEST

src/codegen/extensions/tools/file_operations.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ def view_file(codebase: Codebase, filepath: str) -> dict[str, Any]:
2525
pass
2626

2727
if not file:
28-
for f in codebase.files:
29-
if f.file_path.endswith(filepath):
30-
file = f
31-
break
32-
33-
if not file:
34-
return {"error": f"File not found: {filepath}"}
28+
return {"error": f"File not found: {filepath}. Please use full filepath relative to workspace root."}
3529

3630
return {
3731
"filepath": file.filepath,
@@ -106,6 +100,8 @@ def edit_file(codebase: Codebase, filepath: str, content: str) -> dict[str, Any]
106100
file = codebase.get_file(filepath)
107101
except ValueError:
108102
return {"error": f"File not found: {filepath}"}
103+
if file is None:
104+
return {"error": f"File not found: {filepath}"}
109105

110106
file.edit(content)
111107
codebase.commit()
@@ -144,6 +140,8 @@ def delete_file(codebase: Codebase, filepath: str) -> dict[str, Any]:
144140
file = codebase.get_file(filepath)
145141
except ValueError:
146142
return {"error": f"File not found: {filepath}"}
143+
if file is None:
144+
return {"error": f"File not found: {filepath}"}
147145

148146
file.remove()
149147
codebase.commit()
@@ -165,6 +163,8 @@ def rename_file(codebase: Codebase, filepath: str, new_filepath: str) -> dict[st
165163
file = codebase.get_file(filepath)
166164
except ValueError:
167165
return {"error": f"File not found: {filepath}"}
166+
if file is None:
167+
return {"error": f"File not found: {filepath}"}
168168

169169
if codebase.has_file(new_filepath):
170170
return {"error": f"Destination file already exists: {new_filepath}"}
@@ -204,6 +204,8 @@ def move_symbol(
204204
source = codebase.get_file(source_file)
205205
except ValueError:
206206
return {"error": f"Source file not found: {source_file}"}
207+
if source is None:
208+
return {"error": f"Source file not found: {source_file}"}
207209

208210
try:
209211
target = codebase.get_file(target_file)

src/codegen/git/repo_operator/local_repo_operator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from codegen.git.repo_operator.repo_operator import RepoOperator
1313
from codegen.git.schemas.enums import FetchResult
1414
from codegen.git.schemas.repo_config import RepoConfig
15+
from codegen.git.utils.clone_url import add_access_token_to_url
1516
from codegen.git.utils.file_utils import create_files
17+
from codegen.shared.configs.session_configs import config
1618

1719
logger = logging.getLogger(__name__)
1820

@@ -112,6 +114,9 @@ def create_from_repo(cls, repo_path: str, url: str, access_token: str | None = N
112114
url (str): Git URL of the repository
113115
access_token (str | None): Optional GitHub API key for operations that need GitHub access
114116
"""
117+
access_token = access_token or config.secrets.github_token
118+
url = add_access_token_to_url(url=url, token=access_token)
119+
115120
# Check if repo already exists
116121
if os.path.exists(repo_path):
117122
try:

src/codegen/sdk/core/codebase.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,10 @@ def set_session_options(self, **kwargs: Unpack[SessionOptions]) -> None:
12231223
@classmethod
12241224
def from_repo(
12251225
cls,
1226-
repo_name: str,
1226+
repo_full_name: str,
12271227
*,
1228-
tmp_dir: str | None = None,
1228+
tmp_dir: str | None = "/tmp/codegen",
12291229
commit: str | None = None,
1230-
shallow: bool = True,
12311230
programming_language: ProgrammingLanguage | None = None,
12321231
config: CodebaseConfig = DefaultConfig,
12331232
) -> "Codebase":
@@ -1244,23 +1243,21 @@ def from_repo(
12441243
Returns:
12451244
Codebase: A Codebase instance initialized with the cloned repository
12461245
"""
1247-
logger.info(f"Fetching codebase for {repo_name}")
1246+
logger.info(f"Fetching codebase for {repo_full_name}")
12481247

12491248
# Parse repo name
1250-
if "/" not in repo_name:
1249+
if "/" not in repo_full_name:
12511250
msg = "repo_name must be in format 'owner/repo'"
12521251
raise ValueError(msg)
1253-
owner, repo = repo_name.split("/")
1252+
owner, repo = repo_full_name.split("/")
12541253

12551254
# Setup temp directory
1256-
if tmp_dir is None:
1257-
tmp_dir = "/tmp/codegen"
12581255
os.makedirs(tmp_dir, exist_ok=True)
12591256
logger.info(f"Using directory: {tmp_dir}")
12601257

12611258
# Setup repo path and URL
12621259
repo_path = os.path.join(tmp_dir, repo)
1263-
repo_url = f"https://github.com/{repo_name}.git"
1260+
repo_url = f"https://github.com/{repo_full_name}.git"
12641261
logger.info(f"Will clone {repo_url} to {repo_path}")
12651262

12661263
try:
Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
11
import os
22

33
import pytest
4-
from git import Repo as GitRepo
54

6-
from codegen.git.repo_operator.local_repo_operator import LocalRepoOperator
7-
from codegen.git.schemas.repo_config import RepoConfig
8-
from codegen.git.utils.clone_url import get_authenticated_clone_url_for_repo_config
9-
from codegen.sdk.codebase.config import ProjectConfig
105
from codegen.sdk.core.codebase import Codebase
11-
from codegen.shared.configs.session_configs import config
6+
from codegen.shared.enums.programming_language import ProgrammingLanguage
127

138

149
@pytest.fixture
15-
def repo_config(tmpdir):
16-
repo_config = RepoConfig(
17-
name="Kevin-s-Adventure-Game",
18-
full_name="codegen-sh/Kevin-s-Adventure-Game",
19-
base_dir=str(tmpdir),
20-
)
21-
yield repo_config
22-
23-
24-
@pytest.fixture
25-
def op(repo_config):
26-
os.chdir(repo_config.base_dir)
27-
GitRepo.clone_from(url=get_authenticated_clone_url_for_repo_config(repo_config, token=config.secrets.github_token), to_path=os.path.join(repo_config.base_dir, repo_config.name), depth=1)
28-
op = LocalRepoOperator(repo_config=repo_config)
29-
yield op
30-
31-
32-
@pytest.fixture
33-
def codebase(op: LocalRepoOperator):
34-
project_config = ProjectConfig(repo_operator=op)
35-
codebase = Codebase(projects=[project_config])
10+
def codebase(tmpdir):
11+
os.chdir(tmpdir)
12+
codebase = Codebase.from_repo(repo_full_name="codegen-sh/Kevin-s-Adventure-Game", tmp_dir=tmpdir, programming_language=ProgrammingLanguage.PYTHON)
3613
yield codebase

0 commit comments

Comments
 (0)