Skip to content

Commit 1132d5b

Browse files
author
Lea Evers
committed
recreate tempfile for each branch
1 parent 3051934 commit 1132d5b

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

source/collect_plugins.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,14 @@ def retrieve_plugin_markdown_files(repo_url: str, branches: [str], section: str)
345345
fetch the intro.md and further.md doc files provided by plugins
346346
"""
347347
docs_path = f"docs/{section}.md"
348-
tmpdir = tempfile.mkdtemp()
349348
for branch in branches:
350349
try:
351-
repo = git.Repo.clone_from(repo_url, to_path=tmpdir, bare=True)
352-
docs_content = repo.git.show(f"{branch}:{docs_path}")
353-
shutil.rmtree(tmpdir)
350+
with tempfile.TemporaryDirectory() as tmpdir:
351+
repo = git.Repo.clone_from(repo_url, to_path=tmpdir, bare=True)
352+
docs_content = repo.git.show(f"{branch}:{docs_path}")
354353
return docs_content
355354
except git.GitCommandError as e:
356355
print(f"Failed to get cached git source file {branch}:{docs_path}: {e}. ")
357-
shutil.rmtree(tmpdir)
358356

359357

360358
def get_docs(repository: str | None, section: str, branches=["main", "master"]):

0 commit comments

Comments
 (0)