Starting Tooling Git

Git Stats

Mi'kail Eli'yah
3 min readOct 22, 2024
Nokogiriyama, Chiba Prefecture (鋸山, 千葉県)

Let’s get the stats to a csv file.

import requests
import pandas as pd

# Define the GitHub user
user = "ursa-mikail"

# GitHub API endpoint for user's repositories
repos_url = f"https://api.github.com/users/{user}/repos"

# Fetch all repositories
response = requests.get(repos_url)
repos_data = response.json()

# Initialize list to hold commit data
all_commits_data = []

# Loop through each repository
for repo in repos_data:
repo_name = repo['name']
print(f"Fetching commits for repository: {repo_name}")

# GitHub API endpoint for commits in the repository
commits_url = f"https://api.github.com/repos/{user}/{repo_name}/commits"

page = 1
while True:
response = requests.get(commits_url, params={'per_page': 100, 'page': page})
response_data = response.json()

# Break the loop if no more commits are returned
if len(response_data) == 0:
break

# Process the response data
for commit in response_data:
commit_date = commit['commit']['author']['date'][:10] # Get the date (YYYY-MM-DD)
#commit_date = commit_date.replace("-", ".") # Replace '-' with '.'…

--

--

Mi'kail Eli'yah
Mi'kail Eli'yah

No responses yet