mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
Refactored get_lines_with_commit_hash
to extract commit hashes and lines separately.
This commit is contained in:
parent
53a3b30a93
commit
ff4ef0cf95
1 changed files with 7 additions and 24 deletions
|
@ -6,7 +6,7 @@ from aider.dump import dump
|
||||||
|
|
||||||
def get_lines_with_commit_hash(filename):
|
def get_lines_with_commit_hash(filename):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["git", "blame", "--line-porcelain", filename],
|
["git", "blame", "-l", filename],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
check=True
|
check=True
|
||||||
|
@ -14,30 +14,13 @@ def get_lines_with_commit_hash(filename):
|
||||||
|
|
||||||
lines_with_hash = []
|
lines_with_hash = []
|
||||||
commit_hash = None
|
commit_hash = None
|
||||||
line_content = None
|
|
||||||
|
|
||||||
for line in result.stdout.splitlines():
|
hashes = [
|
||||||
if line.startswith("author "):
|
line.split[0]
|
||||||
pass
|
for line in result.stdout.splitlines()
|
||||||
elif line.startswith("committer "):
|
]
|
||||||
pass
|
lines = Path(filename).splitlines()
|
||||||
elif line.startswith("summary "):
|
|
||||||
pass
|
|
||||||
elif line.startswith("previous "):
|
|
||||||
pass
|
|
||||||
elif line.startswith("filename "):
|
|
||||||
pass
|
|
||||||
elif line.startswith("\t"):
|
|
||||||
line_content = line[1:]
|
|
||||||
elif line.startswith("boundary"):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
commit_hash = line.split(" ")[0]
|
|
||||||
if commit_hash and line_content:
|
|
||||||
lines_with_hash.append(f"{commit_hash}: {line_content}")
|
|
||||||
line_content = None
|
|
||||||
|
|
||||||
return lines_with_hash
|
|
||||||
|
|
||||||
def get_aider_commits():
|
def get_aider_commits():
|
||||||
"""Get commit hashes for commits with messages starting with 'aider:'"""
|
"""Get commit hashes for commits with messages starting with 'aider:'"""
|
||||||
|
@ -64,4 +47,4 @@ if __name__ == "__main__":
|
||||||
print(f"Usage: {sys.argv[0]} <filename>")
|
print(f"Usage: {sys.argv[0]} <filename>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
mark_aider_lines(sys.argv[1])
|
get_lines_with_commit_hash(sys.argv[1])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue