| 12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env python3
- '''
- git blame a file repeatedly, showing the blame at previous versions
- '''
- import re
- import subprocess
- import sys
- def main():
- commit = 'HEAD'
- while True:
- blame = subprocess.Popen(['git-blame', *sys.argv[1:], commit],
- stdout=subprocess.PIPE)
- try:
- blame = subprocess.Popen(['delta', '--color-only'],
- stdin=blame.stdout, stdout=subprocess.PIPE)
- except FileNotFoundError:
- pass
- fzf = subprocess.run(['fzf', '--no-sort', '--tiebreak=index', '--reverse', '--ansi'],
- stdin=blame.stdout, stdout=subprocess.PIPE, text=True)
- blame.wait()
- if fzf.returncode in (1, 130): # no match, esc
- return
- commit = re.search('[0-9a-f]{7,40}', fzf.stdout).group(0) + '^'
- if __name__ == '__main__':
- main()
|