mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 20:25:01 +00:00
Added a function to mark lines in a file that were contributed by aider commits.
This commit is contained in:
parent
f7af56c53c
commit
726b609175
1 changed files with 25 additions and 0 deletions
|
@ -21,5 +21,30 @@ def get_aider_commits():
|
||||||
|
|
||||||
return 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 __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print(f"Usage: {sys.argv[0]} <filename>")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
mark_aider_lines(sys.argv[1])
|
mark_aider_lines(sys.argv[1])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue