mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-09 15:52:38 +02:00
feat: archive
This commit is contained in:
parent
e9471ed206
commit
9339eab20c
5 changed files with 97 additions and 9 deletions
|
|
@ -166,4 +166,4 @@ class FileRepository:
|
|||
"""
|
||||
current_time = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
guid_suffix = str(uuid.uuid4())[:8]
|
||||
return f"{current_time}t{guid_suffix}"
|
||||
return f"{current_time}x{guid_suffix}"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from git.repo import Repo
|
|||
from git.repo.fun import is_git_dir
|
||||
|
||||
from metagpt.const import WORKSPACE_ROOT
|
||||
from metagpt.logs import logger
|
||||
from metagpt.utils.dependency_file import DependencyFile
|
||||
from metagpt.utils.file_repository import FileRepository
|
||||
|
||||
|
|
@ -170,6 +171,21 @@ class GitRepository:
|
|||
self._dependency = DependencyFile(workdir=self.workdir)
|
||||
return self._dependency
|
||||
|
||||
def rename_root(self, new_dir_name):
|
||||
"""Rename the root directory of the Git repository.
|
||||
|
||||
:param new_dir_name: The new name for the root directory.
|
||||
"""
|
||||
if self.workdir.name == new_dir_name:
|
||||
return
|
||||
new_path = self.workdir.parent / new_dir_name
|
||||
if new_path.exists():
|
||||
logger.info(f"Delete directory {str(new_path)}")
|
||||
shutil.rmtree(new_path)
|
||||
self.workdir.rename(new_path)
|
||||
logger.info(f"Rename directory {str(self.workdir)} to {str(new_path)}")
|
||||
self._repository = Repo(new_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
path = WORKSPACE_ROOT / "git"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue