Skip to content

Instantly share code, notes, and snippets.

View peterwj's full-sized avatar

Peter Johnston peterwj

  • Harvard
  • Cambridge / San Francisco
  • 21:28 (UTC -04:00)
View GitHub Profile
peterwj / pre-commit
Created May 12, 2017 18:26
git pre-commit gist for catching merge conflict markers
#!/usr/bin/env python3
import subprocess
import sys
def get_diff():
base_commit =['git', 'rev-parse', '--verify', 'HEAD'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
return['git', 'diff', '--cached', base_commit], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
def check_for_merge_markers(diff):