Skip to content

Commit

Permalink
Workspace path not exists case
Browse files Browse the repository at this point in the history
  • Loading branch information
rusiaaman committed Dec 25, 2024
1 parent 085b749 commit f5907cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/wcgw/client/repo_ops/repo_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pygit2 import GitError, Repository

from .display_tree import DirectoryTree
from .path_prob import FastPathAnalyzer
from wcgw.client.repo_ops.display_tree import DirectoryTree
from wcgw.client.repo_ops.path_prob import FastPathAnalyzer

curr_folder = Path(__file__).parent
vocab_file = curr_folder / "paths_model.vocab"
Expand Down Expand Up @@ -51,7 +51,7 @@ def get_all_files_max_depth(


def get_repo_context(file_or_repo_path: str, max_files: int) -> tuple[str, Path]:
file_or_repo_path_ = Path(file_or_repo_path)
file_or_repo_path_ = Path(file_or_repo_path).absolute()

repo = find_ancestor_with_git(file_or_repo_path_)

Expand Down
14 changes: 9 additions & 5 deletions src/wcgw/client/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,18 @@ def initialize(
reset_shell()

repo_context = ""

if any_workspace_path:
repo_context, folder_to_start = get_repo_context(any_workspace_path, 200)
if os.path.exists(any_workspace_path):
repo_context, folder_to_start = get_repo_context(any_workspace_path, 200)

BASH_STATE.shell.sendline(f"cd {shlex.quote(str(folder_to_start))}")
BASH_STATE.shell.expect(PROMPT, timeout=0.2)
BASH_STATE.update_cwd()
BASH_STATE.shell.sendline(f"cd {shlex.quote(str(folder_to_start))}")
BASH_STATE.shell.expect(PROMPT, timeout=0.2)
BASH_STATE.update_cwd()

repo_context = f"---\n# Workspace structure\n{repo_context}\n---\n"
repo_context = f"---\n# Workspace structure\n{repo_context}\n---\n"
else:
return f"\nInfo: Workspace path {any_workspace_path} does not exist\n"

initial_files_context = ""
if read_files_:
Expand Down

0 comments on commit f5907cf

Please sign in to comment.