mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
Refactored process function to process_fnames and added process_repo to handle repository level processing.
This commit is contained in:
parent
293cc6c684
commit
1cef96ce16
1 changed files with 25 additions and 16 deletions
|
@ -54,37 +54,46 @@ def get_aider_commits():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process(fnames):
|
def process_fnames(fnames, git_dname):
|
||||||
aider_commits = get_aider_commits()
|
if not git_dname:
|
||||||
|
git_dname = "."
|
||||||
|
|
||||||
|
aider_commits = get_aider_commits(git_dname)
|
||||||
total_lines = 0
|
total_lines = 0
|
||||||
total_aider_lines = 0
|
total_aider_lines = 0
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits)
|
num_lines, num_aider_lines = get_lines_with_commit_hash(fname, aider_commits, git_dname)
|
||||||
total_lines += num_lines
|
total_lines += num_lines
|
||||||
total_aider_lines += num_aider_lines
|
total_aider_lines += num_aider_lines
|
||||||
percent_modified = (num_aider_lines / num_lines) * 100 if num_lines > 0 else 0
|
percent_modified = (num_aider_lines / num_lines) * 100 if num_lines > 0 else 0
|
||||||
print(f"{fname}: {num_aider_lines}/{num_lines} lines modified by aider ({percent_modified:.2f}%)")
|
if not num_aider_lines:
|
||||||
|
continue
|
||||||
|
print(f"{fname}: {num_aider_lines}/{num_lines} ({percent_modified:.2f}%)")
|
||||||
|
|
||||||
total_percent_modified = (total_aider_lines / total_lines) * 100 if total_lines > 0 else 0
|
total_percent_modified = (total_aider_lines / total_lines) * 100 if total_lines > 0 else 0
|
||||||
print(f"Total: {total_aider_lines}/{total_lines} lines modified by aider ({total_percent_modified:.2f}%)")
|
print(f"Total: {total_aider_lines}/{total_lines} lines by aider ({total_percent_modified:.2f}%)")
|
||||||
|
return total_percent_modified
|
||||||
|
|
||||||
|
def process_repo(git_dname=None):
|
||||||
|
if not git_dname:
|
||||||
|
git_dname = "."
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "-C", git_dname, "ls-files"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
fnames = [fname for fname in result.stdout.splitlines() if fname.endswith('.py')]
|
||||||
|
process_fnames(fnames, git_dname)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
result = subprocess.run(
|
process_repo()
|
||||||
["git", "ls-files"],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
check=True
|
|
||||||
)
|
|
||||||
fnames = [fname for fname in result.stdout.splitlines() if fname.endswith('.py')]
|
|
||||||
if not fnames:
|
|
||||||
print("No Python files found in the repository.")
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
else:
|
||||||
fnames = sys.argv[1:]
|
fnames = sys.argv[1:]
|
||||||
|
|
||||||
process(sys.argv[1:])
|
process_fnames(fnames)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue