Skip to content

Instantly share code, notes, and snippets.

View peterwj's full-sized avatar
🐙
Octopus

Peter Johnston peterwj

🐙
Octopus
  • Harvard
  • Cambridge / San Francisco
  • 22:51 (UTC -05:00)
View GitHub Profile
@peterwj
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 = subprocess.run(['git', 'rev-parse', '--verify', 'HEAD'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
return subprocess.run(['git', 'diff', '--cached', base_commit], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
def check_for_merge_markers(diff):