Skip to content

Commit

Permalink
Merge pull request #716 from iorisa/fixbug/rename_dir
Browse files Browse the repository at this point in the history
fixbug: rename folder does not work in windows os
  • Loading branch information
geekan authored Jan 8, 2024
2 parents 708748d + 2ec2e71 commit 6613237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metagpt/roles/engineer.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ async def _is_pass(self, summary) -> (str, str):

async def _think(self) -> Action | None:
if not CONFIG.src_workspace:
CONFIG.src_workspace = CONFIG.git_repo.workdir / CONFIG.git_repo.workdir.name
project_name = CONFIG.project_name or CONFIG.git_repo.workdir.name
CONFIG.src_workspace = CONFIG.git_repo.workdir / project_name
write_code_filters = any_to_str_set([WriteTasks, SummarizeCode, FixBug])
summarize_code_filters = any_to_str_set([WriteCode, WriteCodeReview])
if not self.rc.news:
Expand Down
7 changes: 7 additions & 0 deletions metagpt/utils/git_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,17 @@ def rename_root(self, new_dir_name):
if new_path.exists():
logger.info(f"Delete directory {str(new_path)}")
shutil.rmtree(new_path)
if new_path.exists(): # Recheck for windows os
logger.warning(f"Failed to delete directory {str(new_path)}")
return
try:
shutil.move(src=str(self.workdir), dst=str(new_path))
except Exception as e:
logger.warning(f"Move {str(self.workdir)} to {str(new_path)} error: {e}")
finally:
if not new_path.exists(): # Recheck for windows os
logger.warning(f"Failed to move {str(self.workdir)} to {str(new_path)}")
return
logger.info(f"Rename directory {str(self.workdir)} to {str(new_path)}")
self._repository = Repo(new_path)
self._gitignore_rules = parse_gitignore(full_path=str(new_path / ".gitignore"))
Expand Down

0 comments on commit 6613237

Please sign in to comment.