bluenevus commited on
Commit
76b7ac8
·
verified ·
1 Parent(s): 5c0a4f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  from datetime import datetime, timedelta
3
- import requests
4
  import google.generativeai as genai
5
  from github import Github, GithubException
6
 
@@ -10,6 +9,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
10
  g = Github(github_token)
11
 
12
  # Extract owner and repo from the URL
 
13
  parts = github_url.rstrip('/').split('/')
14
  owner = parts[-2]
15
  repo_name = parts[-1]
@@ -18,8 +18,9 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
18
  repo = g.get_repo(f"{owner}/{repo_name}")
19
 
20
  # Get commits between start_date and end_date
21
- commits = repo.get_commits(since=datetime.strptime(start_date, "%Y-%m-%d"),
22
- until=datetime.strptime(end_date, "%Y-%m-%d"))
 
23
 
24
  # Prepare commit messages
25
  commit_messages = [commit.commit.message for commit in commits]
@@ -52,7 +53,7 @@ def generate_release_notes(github_url, github_token, gemini_api_key, start_date,
52
  if e.status == 401:
53
  return "Error: Invalid GitHub token or insufficient permissions."
54
  elif e.status == 404:
55
- return "Error: Repository not found. Please check the GitHub URL."
56
  else:
57
  return f"GitHub API error: {str(e)}"
58
  except Exception as e:
@@ -76,7 +77,7 @@ iface = gr.Interface(
76
  ),
77
  gr.Textbox(
78
  label="End Date",
79
- placeholder="YYYY-MM-DD",
80
  value=default_end_date.strftime("%Y-%m-%d"),
81
  )
82
  ],
 
1
  import gradio as gr
2
  from datetime import datetime, timedelta
 
3
  import google.generativeai as genai
4
  from github import Github, GithubException
5
 
 
9
  g = Github(github_token)
10
 
11
  # Extract owner and repo from the URL
12
+ github_url = github_url.rstrip('.git') # Remove .git if present
13
  parts = github_url.rstrip('/').split('/')
14
  owner = parts[-2]
15
  repo_name = parts[-1]
 
18
  repo = g.get_repo(f"{owner}/{repo_name}")
19
 
20
  # Get commits between start_date and end_date
21
+ start_date = datetime.strptime(start_date, "%Y-%m-%d")
22
+ end_date = datetime.strptime(end_date, "%Y-%m-%d")
23
+ commits = list(repo.get_commits(since=start_date, until=end_date))
24
 
25
  # Prepare commit messages
26
  commit_messages = [commit.commit.message for commit in commits]
 
53
  if e.status == 401:
54
  return "Error: Invalid GitHub token or insufficient permissions."
55
  elif e.status == 404:
56
+ return f"Error: Repository not found. Please check the GitHub URL. Attempted to access: {owner}/{repo_name}"
57
  else:
58
  return f"GitHub API error: {str(e)}"
59
  except Exception as e:
 
77
  ),
78
  gr.Textbox(
79
  label="End Date",
80
+ placeholder="YYYY-MM-D",
81
  value=default_end_date.strftime("%Y-%m-%d"),
82
  )
83
  ],