Added a function to mark lines in a file that were contributed by aider commits.

This commit is contained in:
Paul Gauthier 2024-05-24 08:25:41 -07:00
parent f7af56c53c
commit 726b609175

View file

@ -21,5 +21,30 @@ def get_aider_commits():
return commits
import sys
def mark_aider_lines(filename):
aider_commits = set(get_aider_commits())
with open(filename, "r") as f:
lines = f.readlines()
for i, line in enumerate(lines, start=1):
result = subprocess.run(
["git", "blame", "-L", f"{i},{i}", "--porcelain", filename],
capture_output=True,
text=True,
check=True
)
commit_hash = result.stdout.split(" ")[0]
if commit_hash in aider_commits:
print(f"* {line}", end="")
else:
print(f" {line}", end="")
if __name__ == "__main__":
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} <filename>")
sys.exit(1)
mark_aider_lines(sys.argv[1])