mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
Implemented script to get commit author line counts for all Python files in the repository.
This commit is contained in:
parent
238b8d018a
commit
1a9adca83c
1 changed files with 14 additions and 3 deletions
|
@ -7,6 +7,7 @@ import argparse
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from aider.dump import dump
|
from aider.dump import dump
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def get_all_commit_hashes_since_tag(tag):
|
def get_all_commit_hashes_since_tag(tag):
|
||||||
|
@ -50,20 +51,30 @@ def main():
|
||||||
|
|
||||||
authors = get_commit_authors(commits)
|
authors = get_commit_authors(commits)
|
||||||
|
|
||||||
get_counts_for_file(args.tag, authors, "aider/help.py")
|
py_files = run(['git', 'ls-files', '*.py']).strip().split('\n')
|
||||||
|
|
||||||
|
all_file_counts = {}
|
||||||
|
for file in py_files:
|
||||||
|
file_counts = get_counts_for_file(args.tag, authors, file)
|
||||||
|
if file_counts:
|
||||||
|
all_file_counts[file] = file_counts
|
||||||
|
|
||||||
|
dump(all_file_counts)
|
||||||
|
|
||||||
def get_counts_for_file(tag, authors, fname):
|
def get_counts_for_file(tag, authors, fname):
|
||||||
text = run(['git', 'blame', f'{tag}..HEAD', '--', fname])
|
text = run(['git', 'blame', f'{tag}..HEAD', '--', fname])
|
||||||
|
if not text:
|
||||||
|
return None
|
||||||
text = text.splitlines()
|
text = text.splitlines()
|
||||||
line_counts = defaultdict(int)
|
line_counts = defaultdict(int)
|
||||||
for line in text:
|
for line in text:
|
||||||
if line.startswith('^'):
|
if line.startswith('^'):
|
||||||
continue
|
continue
|
||||||
hsh = line[:hash_len]
|
hsh = line[:hash_len]
|
||||||
author = authors[hsh]
|
author = authors.get(hsh, "Unknown")
|
||||||
line_counts[author] += 1
|
line_counts[author] += 1
|
||||||
|
|
||||||
dump(line_counts)
|
return dict(line_counts)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue