🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
rm basic git operation
garylin2099b21371bb3ffd
diff --git a/metagpt/tools/libs/git.py b/metagpt/tools/libs/git.pyindex 44acb1bb0..f6e02e40f 100644--- a/metagpt/tools/libs/git.py+++ b/metagpt/tools/libs/git.py@@ -12,55 +12,6 @@ from metagpt.tools.tool_registry import register_toolfrom metagpt.utils.git_repository import GitBranch, GitRepository-# @register_tool(tags=["git"])-async def git_clone(url: str, output_dir: str | Path = None) -> Path:- """- Clones a Git repository from the given URL.-- Args:- url (Union[str, Path]): The URL or local path of the Git repository to clone.- output_dir (Union[str, Path], optional): The directory where the repository should be cloned.- If None, the repository will be cloned into the current working directory. Defaults to None.-- Returns:- Path: The path to the cloned repository.-- Example:- >>> url = "https://github.com/iorisa/snake-game.git"- >>> local_path = await git_clone(url=url)- >>> print(local_path)- /local/path/to/snake-game- """- repo = await GitRepository.clone_from(url=url, output_dir=output_dir)- return repo.workdir---@register_tool(- tags=["software development", "git", "Checks out the specific commit/branch/tag of the local Git repository."]-)-async def git_checkout(repo_dir: str | Path, commit_id: str):- """- Checks out a specific commit in a Git repository.-- Args:- repo_dir (str or Path): The directory containing the Git repository.- commit_id (str): The ID of the commit or the name of branch/tag to check out.-- Raises:- ValueError: If the specified Git root is invalid.-- Example:- >>> repo_dir = '/TO/GIT/REPO'- >>> commit_id = 'main'- >>> await git_checkout(repo_dir=repo_dir, commit_id=commit_id)- git checkout main- """- repo = GitRepository(local_path=repo_dir, auto_init=False)- if not repo.is_valid:- ValueError(f"Invalid git root: {repo_dir}")- await repo.checkout(commit_id)--@register_tool(tags=["software development", "git", "Commit the changes and push to remote git repository."])async def git_push(local_path: Union[str, Path],diff --git a/metagpt/utils/git_repository.py b/metagpt/utils/git_repository.pyindex 8fc52579a..7b09c1775 100644--- a/metagpt/utils/git_repository.py+++ b/metagpt/utils/git_repository.py@@ -238,6 +238,8 @@ class GitRepository::param comments: Comments for the archive commit."""logger.info(f"Archive: {list(self.changed_files.keys())}")+ if not self.changed_files:+ returnself.add_change(self.changed_files)self.commit(comments)@@ -271,7 +273,7 @@ class GitRepository:base = self.current_branchhead = base if not new_branch else self.new_branch(new_branch)- self.archive(comments)+ self.archive(comments) # will skip committing if no changesctx = Context()env = ctx.new_environ()proxy = ["-c", f"http.proxy={ctx.config.proxy}"] if ctx.config.proxy else []@@ -288,7 +290,7 @@ class GitRepository:raise BadCredentialsException(status=401, message=info)info = f"{stdout}\n{stderr}\nexit: {return_code}\n"info = info.replace(token, "<TOKEN>")- logger.info(info)+ print(info)return GitBranch(base=base, head=head, repo_name=self.repo_name)