Update app.py
Browse files
app.py
CHANGED
|
@@ -2,21 +2,17 @@ import gradio as gr
|
|
| 2 |
from datetime import datetime, timedelta
|
| 3 |
import google.generativeai as genai
|
| 4 |
from github import Github, GithubException
|
| 5 |
-
from urllib.parse import urlparse
|
| 6 |
|
| 7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
| 8 |
try:
|
| 9 |
# Initialize GitHub client with the token
|
| 10 |
g = Github(github_token)
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
path_parts = parsed_url.path.strip('/').split('/')
|
| 15 |
-
owner = path_parts[0]
|
| 16 |
-
repo_name = '/'.join(path_parts[1:]).rstrip('.git')
|
| 17 |
|
| 18 |
-
# Get the repository
|
| 19 |
-
repo = g.get_repo(
|
| 20 |
|
| 21 |
# Get commits between start_date and end_date
|
| 22 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
|
@@ -54,7 +50,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
|
|
| 54 |
if e.status == 401:
|
| 55 |
return "Error: Invalid GitHub token or insufficient permissions."
|
| 56 |
elif e.status == 404:
|
| 57 |
-
return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {
|
| 58 |
else:
|
| 59 |
return f"GitHub API error: {str(e)}"
|
| 60 |
except Exception as e:
|
|
|
|
| 2 |
from datetime import datetime, timedelta
|
| 3 |
import google.generativeai as genai
|
| 4 |
from github import Github, GithubException
|
|
|
|
| 5 |
|
| 6 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
| 7 |
try:
|
| 8 |
# Initialize GitHub client with the token
|
| 9 |
g = Github(github_token)
|
| 10 |
|
| 11 |
+
# Remove .git suffix if present
|
| 12 |
+
github_url = github_url.rstrip('.git')
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# Get the repository directly using the URL
|
| 15 |
+
repo = g.get_repo(github_url.replace('https://github.com/', ''))
|
| 16 |
|
| 17 |
# Get commits between start_date and end_date
|
| 18 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
|
|
|
| 50 |
if e.status == 401:
|
| 51 |
return "Error: Invalid GitHub token or insufficient permissions."
|
| 52 |
elif e.status == 404:
|
| 53 |
+
return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {github_url}"
|
| 54 |
else:
|
| 55 |
return f"GitHub API error: {str(e)}"
|
| 56 |
except Exception as e:
|