Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -31,18 +31,22 @@ def analyze_github_repo(repo_url):
|
|
31 |
issues = data.get('open_issues_count', 'N/A')
|
32 |
contributors_url = data.get('contributors_url', None)
|
33 |
|
34 |
-
# Get number of contributors
|
35 |
-
contributors =
|
36 |
if contributors_url:
|
37 |
contributors_data = requests.get(contributors_url).json()
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Data to plot
|
41 |
metrics = {
|
42 |
'Stars': stars,
|
43 |
'Forks': forks,
|
44 |
'Open Issues': issues,
|
45 |
-
'Contributors': contributors
|
46 |
}
|
47 |
|
48 |
# Create the bar plot
|
@@ -58,18 +62,25 @@ def analyze_github_repo(repo_url):
|
|
58 |
plt.savefig("/mnt/data/github_analysis.png")
|
59 |
plt.close()
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
# Gradio interface for the tool
|
64 |
iface = gr.Interface(
|
65 |
fn=analyze_github_repo,
|
66 |
inputs=gr.Textbox(label="Enter GitHub Repository URL", placeholder="https://github.com/username/repository"),
|
67 |
-
outputs=gr.Image(label="Repository Analysis Visualization"),
|
68 |
title="GitHub Repository Analysis Tool",
|
69 |
-
description="Enter a GitHub repository URL to get basic analytics including stars, forks, issues, and contributors, along with a visual chart."
|
70 |
)
|
71 |
|
72 |
# Launch the app
|
73 |
iface.launch()
|
74 |
|
75 |
-
|
|
|
31 |
issues = data.get('open_issues_count', 'N/A')
|
32 |
contributors_url = data.get('contributors_url', None)
|
33 |
|
34 |
+
# Get number of contributors and their contributions (commit count)
|
35 |
+
contributors = []
|
36 |
if contributors_url:
|
37 |
contributors_data = requests.get(contributors_url).json()
|
38 |
+
for contributor in contributors_data:
|
39 |
+
contributors.append({
|
40 |
+
'login': contributor['login'],
|
41 |
+
'contributions': contributor['contributions']
|
42 |
+
})
|
43 |
|
44 |
# Data to plot
|
45 |
metrics = {
|
46 |
'Stars': stars,
|
47 |
'Forks': forks,
|
48 |
'Open Issues': issues,
|
49 |
+
'Contributors': len(contributors)
|
50 |
}
|
51 |
|
52 |
# Create the bar plot
|
|
|
62 |
plt.savefig("/mnt/data/github_analysis.png")
|
63 |
plt.close()
|
64 |
|
65 |
+
# Prepare contributor data for display
|
66 |
+
contributor_info = "Contributors and Their Commit Contributions:\n"
|
67 |
+
for contributor in contributors:
|
68 |
+
contributor_info += f"{contributor['login']}: {contributor['contributions']} contributions\n"
|
69 |
+
|
70 |
+
# Combine the visualization link and contributor data
|
71 |
+
result = f"Repository: {repo_url}\n\n{contributor_info}\nImage of Repository Analysis:\n/mnt/data/github_analysis.png"
|
72 |
+
|
73 |
+
return result, "/mnt/data/github_analysis.png"
|
74 |
|
75 |
# Gradio interface for the tool
|
76 |
iface = gr.Interface(
|
77 |
fn=analyze_github_repo,
|
78 |
inputs=gr.Textbox(label="Enter GitHub Repository URL", placeholder="https://github.com/username/repository"),
|
79 |
+
outputs=[gr.Textbox(label="Repository Analysis"), gr.Image(label="Repository Analysis Visualization")],
|
80 |
title="GitHub Repository Analysis Tool",
|
81 |
+
description="Enter a GitHub repository URL to get basic analytics including stars, forks, issues, and contributors, along with a visual chart and contributor details."
|
82 |
)
|
83 |
|
84 |
# Launch the app
|
85 |
iface.launch()
|
86 |
|
|