🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fixbug: gitignore
莘权 马56e19bca9af8
diff --git a/metagpt/utils/repo_to_markdown.py b/metagpt/utils/repo_to_markdown.pyindex 9ca39c061..65065025a 100644--- a/metagpt/utils/repo_to_markdown.py+++ b/metagpt/utils/repo_to_markdown.py@@ -22,7 +22,7 @@ from metagpt.utils.common import (from metagpt.utils.tree import tree-async def repo_to_markdown(repo_path: str | Path, output: str | Path = None, gitignore: str | Path = None) -> str:+async def repo_to_markdown(repo_path: str | Path, output: str | Path = None) -> str:"""Convert a local repository into a markdown representation.@@ -32,17 +32,16 @@ async def repo_to_markdown(repo_path: str | Path, output: str | Path = None, gitArgs:repo_path (str | Path): The path to the local repository.output (str | Path, optional): The path to save the generated markdown file. Defaults to None.- gitignore (str | Path, optional): The path to the .gitignore file. Defaults to None.Returns:str: The markdown representation of the repository."""repo_path = Path(repo_path).resolve()- gitignore = Path(gitignore or Path(__file__).parent / "../../.gitignore").resolve()+ gitignore_file = repo_path / ".gitignore"- markdown = await _write_dir_tree(repo_path=repo_path, gitignore=gitignore)+ markdown = await _write_dir_tree(repo_path=repo_path, gitignore=gitignore_file)- gitignore_rules = parse_gitignore(full_path=str(gitignore))+ gitignore_rules = parse_gitignore(full_path=str(gitignore_file)) if gitignore_file.exists() else Nonemarkdown += await _write_files(repo_path=repo_path, gitignore_rules=gitignore_rules)if output:@@ -64,12 +63,12 @@ async def _write_dir_tree(repo_path: Path, gitignore: Path) -> str:return doc-async def _write_files(repo_path, gitignore_rules) -> str:+async def _write_files(repo_path, gitignore_rules=None) -> str:filenames = list_files(repo_path)markdown = ""pattern = r"^\..*" # Hidden folders/filesfor filename in filenames:- if gitignore_rules(str(filename)):+ if gitignore_rules and gitignore_rules(str(filename)):continueignore = Falsefor i in filename.parts: