Skip to main content (Source)

    Find commits in git repositories under this directory since the given date.
    Used to compile the list of changes for the Numbas development log.
        python 2023-10-01
import argparse
from pathlib import Path
import re
import subprocess
ignore_dirs = ['node_modules', 'media']
def find_git_directories(p):
    if (p / '.git').exists():
        yield p
    for sp in p.iterdir():
        if (not sp.is_dir()) or'.') or in ignore_dirs:
        yield from find_git_directories(sp)
parser = argparse.ArgumentParser()
parser.add_argument('date', help="Date to list commits since")
args = parser.parse_args()
git_directories = sorted(find_git_directories(Path()))
for d in git_directories:
    def run(cmd, **kwargs):
        return, cwd=d, encoding='utf-8', capture_output=True, **kwargs)
    origin = run(['git','remote','get-url','origin']).stdout.strip()
    origin_url = re.sub(r'^\w+@([^:]+):(.*?)(.git)?$', r'https://\1/\2', origin)
    commits = run(['git','log',f'--since="{}"', '--oneline', f'--pretty=format:%as\n  %cn\n\t%s\n\t{origin_url}/commit/%h\n','--reverse'], env={'GIT_PAGER': ''}).stdout
    if commits:
        contributors = set(run(['git','log','--pretty=format:%cn',f'--since="{}"']).stdout.split('\n'))
Contributors: {', '.join(sorted(contributors))}