Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,23 @@ from datetime import datetime, timedelta
|
|
3 |
import google.generativeai as genai
|
4 |
from github import Github, GithubException
|
5 |
import docx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
8 |
try:
|
9 |
g = Github(github_token)
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
repo = g.get_repo(repo_name)
|
14 |
|
15 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
@@ -54,7 +64,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
|
|
54 |
for line in release_notes.split('\n'):
|
55 |
if line.strip().endswith(':'):
|
56 |
doc.add_heading(line.strip(), level=1)
|
57 |
-
elif line.strip().startswith('•') or line.strip()[0].isdigit():
|
58 |
doc.add_paragraph(line.strip(), style='List Bullet')
|
59 |
else:
|
60 |
doc.add_paragraph(line)
|
|
|
3 |
import google.generativeai as genai
|
4 |
from github import Github, GithubException
|
5 |
import docx
|
6 |
+
import re
|
7 |
+
|
8 |
+
def extract_repo_name(github_url):
|
9 |
+
# Use regex to extract the username and repo name from the URL
|
10 |
+
match = re.search(r'github\.com/([^/]+)/([^/]+)', github_url)
|
11 |
+
if match:
|
12 |
+
return f"{match.group(1)}/{match.group(2)}"
|
13 |
+
return None
|
14 |
|
15 |
def generate_release_notes(github_url, github_token, gemini_api_key, start_date, end_date):
|
16 |
try:
|
17 |
g = Github(github_token)
|
18 |
|
19 |
+
repo_name = extract_repo_name(github_url)
|
20 |
+
if not repo_name:
|
21 |
+
return "Error: Invalid GitHub URL format.", None
|
22 |
+
|
23 |
repo = g.get_repo(repo_name)
|
24 |
|
25 |
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
|
|
64 |
for line in release_notes.split('\n'):
|
65 |
if line.strip().endswith(':'):
|
66 |
doc.add_heading(line.strip(), level=1)
|
67 |
+
elif line.strip().startswith('•') or (line.strip() and line.strip()[0].isdigit()):
|
68 |
doc.add_paragraph(line.strip(), style='List Bullet')
|
69 |
else:
|
70 |
doc.add_paragraph(line)
|