feat: Add Aider contribution percentage to badges script

This commit is contained in:
Paul Gauthier (aider) 2025-03-20 14:10:39 -07:00
parent eaac00ad3f
commit a5614bfe40

View file

@ -3,6 +3,7 @@
import argparse
import os
import sys
import yaml
import requests
from dotenv import load_dotenv
@ -48,6 +49,33 @@ def get_github_stars(repo="paul-gauthier/aider"):
return None
def get_aider_percentage():
"""
Get the percentage of code written by Aider in the latest release
from the blame.yml file
"""
blame_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"aider", "website", "_data", "blame.yml"
)
try:
with open(blame_path, 'r') as f:
blame_data = yaml.safe_load(f)
# Get the most recent release (first entry in the list)
if blame_data and len(blame_data) > 0:
latest_release = blame_data[0]
percentage = latest_release.get('aider_percentage', 0)
version = latest_release.get('end_tag', 'unknown')
return percentage, version
return 0, 'unknown'
except Exception as e:
print(f"Error reading blame data: {e}", file=sys.stderr)
return 0, 'unknown'
def main():
# Load environment variables from .env file
load_dotenv()
@ -87,6 +115,10 @@ def main():
stars = get_github_stars(args.github_repo)
if stars is not None:
print(f"GitHub stars for {args.github_repo}: {stars:,}")
# Get Aider contribution percentage in latest release
percentage, version = get_aider_percentage()
print(f"Aider wrote {percentage:.2f}% of code in the latest release ({version})")
if __name__ == "__main__":