Updated get_lines_with_commit_hash to set verbose to True by default and adjusted the iteration logic in history function.

This commit is contained in:
Paul Gauthier 2024-05-24 09:36:12 -07:00
parent eff8aea116
commit 3bba6ec58e

View file

@ -7,7 +7,7 @@ from pathlib import Path
import pylab as plt import pylab as plt
from aider.dump import dump from aider.dump import dump
def get_lines_with_commit_hash(filename, aider_commits, git_dname, verbose=False): def get_lines_with_commit_hash(filename, aider_commits, git_dname, verbose=True):
result = subprocess.run( result = subprocess.run(
["git", "-C", git_dname, "blame", "-l", filename], ["git", "-C", git_dname, "blame", "-l", filename],
capture_output=True, capture_output=True,
@ -116,12 +116,16 @@ def history():
dump(len(commits)) dump(len(commits))
num_commits = len(commits) num_commits = len(commits)
N=3 N=10
step = num_commits//N step = (num_commits-1)/(N-1)
results = [] results = []
for i in range(0, num_commits+1, step): i = 0
dump(i, num_commits) while i < num_commits:
commit = commits[i] commit_num = int(i)
dump(i, commit_num, num_commits)
i += step
commit = commits[commit_num]
repo_dname = tempfile.TemporaryDirectory().name repo_dname = tempfile.TemporaryDirectory().name
cmd = f"git clone . {repo_dname}" cmd = f"git clone . {repo_dname}"
@ -131,7 +135,7 @@ def history():
subprocess.run(cmd.split(), check=True) subprocess.run(cmd.split(), check=True)
aider_lines, total_lines, pct = process_repo(repo_dname) aider_lines, total_lines, pct = process_repo(repo_dname)
results.append((i, aider_lines, total_lines, pct)) results.append((commit_num, aider_lines, total_lines, pct))
dump(results) dump(results)
@ -152,14 +156,14 @@ def history():
def main(): def main():
history() #history()
return #return
if len(sys.argv) < 2: if len(sys.argv) < 2:
return process_repo() return process_repo()
fnames = sys.argv[1:] fnames = sys.argv[1:]
process_fnames(fnames) process_fnames(fnames, ".")
if __name__ == "__main__": if __name__ == "__main__":