Skip to content

Commit

Permalink
fix: Update repository cloning logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
eli64s committed Oct 17, 2023
1 parent d4c9d18 commit e91a396
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "readmeai"
version = "0.4.019"
version = "0.4.023"
description = "🚀 Generate beautiful README.md files from the terminal. Powered by OpenAI's GPT LLMs 💫"
authors = ["Eli <0x.eli.64s@gmail.com>"]
license = "MIT"
Expand Down
14 changes: 3 additions & 11 deletions readmeai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
__package__ = "readmeai"

import asyncio
import shutil
import traceback

from readmeai.core import logger, model, preprocess
Expand Down Expand Up @@ -45,10 +44,9 @@ def main(
config.api.temperature = temperature
config.api.offline_mode = offline_mode
config.git = GitConfig(repository=repository)
(
_,
config.git.name,
) = git.get_user_repository_name(repository)
user, config.git.name = git.get_user_repository_name(repository)
config.api.offline_mode = offline_mode
config.git = GitConfig(repository=repository)
if api_key is None and offline_mode is False:
config.api.offline_mode = offline_mode

Expand All @@ -73,11 +71,7 @@ async def readme_agent(

llm = model.OpenAIHandler(config)

temp_dir = None
try:
temp_dir = await asyncio.to_thread(
git.clone_repo_to_temp_dir, repository
)
temp_dir = git.clone_repo_to_temp_dir(repository)
tree_str = tree.generate_tree(temp_dir, repository)
tree_str = tree.format_tree(name, tree_str)
Expand Down Expand Up @@ -130,8 +124,6 @@ async def readme_agent(
)

finally:
if temp_dir:
await asyncio.to_thread(shutil.rmtree, temp_dir)
await llm.close()

logger.info("README-AI execution complete.")
5 changes: 2 additions & 3 deletions readmeai/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import os
import platform
import re
import shutil
import tempfile
from pathlib import Path
from typing import Optional
from typing import Optional, Tuple

import git

Expand Down Expand Up @@ -94,7 +93,7 @@ def get_github_file_link(file: str, repo: str, user_repo_name: str) -> str:
return base_urls["github.com"]


def get_user_repository_name(url_or_path) -> (str, str):
def get_user_repository_name(url_or_path) -> Tuple(str, str):
"""
Extract username and repository name from a
GitHub, Bitbucket, or GitLab URL or local path.
Expand Down

0 comments on commit e91a396

Please sign in to comment.