From e8a5af089f954fde6f290bd0b79173004c22f7d8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 7 Jul 2024 13:10:31 -0300 Subject: [PATCH] Implemented a function to get all commit hashes since a specified tag and added a function to get the commit authors. --- scripts/blame.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/scripts/blame.py b/scripts/blame.py index 84293e70d..ad441c8fb 100755 --- a/scripts/blame.py +++ b/scripts/blame.py @@ -7,34 +7,48 @@ import argparse from pathlib import Path from aider.dump import dump + def get_all_commit_hashes_since_tag(tag): + res = run(["git", "rev-list", f"{tag}..HEAD"]) + + if res: + commit_hashes = res.strip().split('\n') + return commit_hashes + +def run(cmd): try: # Get all commit hashes since the specified tag result = subprocess.run( - ["git", "rev-list", f"{tag}..HEAD"], + cmd, capture_output=True, text=True, check=True ) - # Split the output into individual commit hashes - commit_hashes = result.stdout.strip().split('\n') - return commit_hashes + return result.stdout except subprocess.CalledProcessError as e: print(f"Error: {e}", file=sys.stderr) - return [] + return + +def get_commit_authors(commits): + commit_to_author = dict() + def main(): parser = argparse.ArgumentParser(description="Get commit hashes since a specified tag.") parser.add_argument("tag", help="The tag to start from") args = parser.parse_args() - commit_hashes = get_all_commit_hashes_since_tag(args.tag) - if commit_hashes: - print("Commit hashes since tag", args.tag) - for hash in commit_hashes: - print(hash) - else: - print("No commit hashes found or an error occurred.") + commits = get_all_commit_hashes_since_tag(args.tag) + commits = [commit[:len('44e6fefc2')] for commit in commits] + dump(commits) + + authors = get_commit_authors(commits) + + + #text = run(['git', 'blame', f'{args.tag}..HEAD', '--', 'aider/main.py']) + #text = text.splitlines() + + if __name__ == "__main__": main()