mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
![]() # Aider chat conversation: USER: i want to do something like `git blame` but i rather than marking each line with the author i want to mark all the code lines which were introduced from a commit with a commit message that starts with a specific string: "aider:" ASSISTANT: To achieve this, we need to: 1. Parse the git log to find commits with messages starting with "aider:". 2. Use `git blame` to find the lines introduced by these commits. 3. Mark these lines in the code. Here is the implementation: scripts/blame.py ```python <<<<<<< SEARCH ======= import subprocess def get_aider_commits(): """Get commit hashes for commits with messages starting with 'aider:'""" result = subprocess.run( ["git", "log", "--pretty=format:%H %s"], capture_output=True, text=True, check=True ) commits = [] for line in result.stdout.splitlines(): commit_hash, commit_message = line.split(" ", 1) if commit_message.startswith("aider:"): commits.append(commit_hash) return commits def get_blame_lines(commit_hash): """Get lines introduced by a specific commit""" result = subprocess.run( ["git", "blame", "--line-porcelain", commit_hash], capture_output=True, text=True, check=True ) lines = [] for line in result.stdout.splitlines(): if line.startswith("author "): lines.append(line) return lines def mark_aider_lines(): """Mark lines introduced by 'aider:' commits""" aider_commits = get_aider_commits() for commit in aider_commits: blame_lines = get_blame_lines(commit) for line in blame_lines: print(f"AIDER: {line}") if __name__ == "__main__": mark_aider_lines() >>>>>>> REPLACE ``` This script will: 1. Find all commits with messages starting with "aider:". 2. Use `git blame` to find the lines introduced by these commits. 3. Print these lines prefixed with "AIDER:". |
||
---|---|---|
.. | ||
blame.py | ||
Dockerfile.jekyll | ||
jekyll_build.sh | ||
jekyll_run.sh | ||
versionbump.py |