Skip to content

Instantly share code, notes, and snippets.

View peterwj's full-sized avatar
🐙
Octopus

Peter Johnston peterwj

🐙
Octopus
  • Harvard
  • Cambridge / San Francisco
  • 21:28 (UTC -04: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):