Skip to content

Commit b2392d2

Browse files
committed
fix: Update repository cloning logic.
1 parent d4c9d18 commit b2392d2

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "readmeai"
7-
version = "0.4.019"
7+
version = "0.4.025"
88
description = "🚀 Generate beautiful README.md files from the terminal. Powered by OpenAI's GPT LLMs 💫"
99
authors = ["Eli <0x.eli.64s@gmail.com>"]
1010
license = "MIT"

readmeai/main.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
__package__ = "readmeai"
66

77
import asyncio
8-
import shutil
98
import traceback
109

1110
from readmeai.core import logger, model, preprocess
@@ -45,10 +44,8 @@ def main(
4544
config.api.temperature = temperature
4645
config.api.offline_mode = offline_mode
4746
config.git = GitConfig(repository=repository)
48-
(
49-
_,
50-
config.git.name,
51-
) = git.get_user_repository_name(repository)
47+
_, config.git.name = git.get_user_repository_name(repository)
48+
5249
if api_key is None and offline_mode is False:
5350
config.api.offline_mode = offline_mode
5451

@@ -73,11 +70,7 @@ async def readme_agent(
7370

7471
llm = model.OpenAIHandler(config)
7572

76-
temp_dir = None
7773
try:
78-
temp_dir = await asyncio.to_thread(
79-
git.clone_repo_to_temp_dir, repository
80-
)
8174
temp_dir = git.clone_repo_to_temp_dir(repository)
8275
tree_str = tree.generate_tree(temp_dir, repository)
8376
tree_str = tree.format_tree(name, tree_str)
@@ -130,8 +123,6 @@ async def readme_agent(
130123
)
131124

132125
finally:
133-
if temp_dir:
134-
await asyncio.to_thread(shutil.rmtree, temp_dir)
135126
await llm.close()
136127

137128
logger.info("README-AI execution complete.")

readmeai/utils/git.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import platform
55
import re
6-
import shutil
76
import tempfile
87
from pathlib import Path
98
from typing import Optional
@@ -94,14 +93,14 @@ def get_github_file_link(file: str, repo: str, user_repo_name: str) -> str:
9493
return base_urls["github.com"]
9594

9695

97-
def get_user_repository_name(url_or_path) -> (str, str):
96+
def get_user_repository_name(url_or_path):
9897
"""
9998
Extract username and repository name from a
10099
GitHub, Bitbucket, or GitLab URL or local path.
101100
"""
102101

103102
if os.path.exists(url_or_path):
104-
return os.path.basename(url_or_path)
103+
return "local", os.path.basename(url_or_path)
105104

106105
patterns = {
107106
"github": r"https?://github.com/([^/]+)/([^/]+)",

0 commit comments

Comments
 (0)