Spaces:
Sleeping
Sleeping
Neodpy
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,20 @@ def generate_docs(repo_id: str) -> str:
|
|
| 8 |
Fetches repository details from GitHub and generates documentation using the Groq API.
|
| 9 |
"""
|
| 10 |
# Fetch basic repo info from GitHub
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
if response.status_code != 200:
|
| 14 |
return f"Error: Unable to fetch repository details for '{repo_id}'. Please check the repository ID."
|
| 15 |
-
|
| 16 |
repo_data = response.json()
|
| 17 |
repo_description = repo_data.get("description", "No description provided.")
|
| 18 |
readme = repo_data.get("README.md", "No description provided.")
|
|
|
|
| 8 |
Fetches repository details from GitHub and generates documentation using the Groq API.
|
| 9 |
"""
|
| 10 |
# Fetch basic repo info from GitHub
|
| 11 |
+
if repo_id.endswith(".git"):
|
| 12 |
+
repo_id = repo_id[:-4]
|
| 13 |
+
prefix = "github.com/"
|
| 14 |
+
start = repo_id.find(prefix)
|
| 15 |
+
if start != -1:
|
| 16 |
+
# Offset start by length of prefix
|
| 17 |
+
repo_path = repo_id[start + len(prefix):]
|
| 18 |
+
print(repo_path)
|
| 19 |
+
else:
|
| 20 |
+
print("Invalid URL format")
|
| 21 |
+
response = requests.get(repo_path)
|
| 22 |
if response.status_code != 200:
|
| 23 |
return f"Error: Unable to fetch repository details for '{repo_id}'. Please check the repository ID."
|
| 24 |
+
url = f"https://api.github.com/repos/{repo_path}"
|
| 25 |
repo_data = response.json()
|
| 26 |
repo_description = repo_data.get("description", "No description provided.")
|
| 27 |
readme = repo_data.get("README.md", "No description provided.")
|