Skip to content

Instantly share code, notes, and snippets.

@RyanParsley
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save RyanParsley/af3886affbe760a72339 to your computer and use it in GitHub Desktop.

Select an option

Save RyanParsley/af3886affbe760a72339 to your computer and use it in GitHub Desktop.
Don't let poorly handled conflicts honey badger your repo
#!/bin/bash
# CONFIG
# Give options empty values to bypass checks ("OPTIONNAME=")
# whether to check ig git merge conflicts have been added
CONFLICTS=1
# Simple check for merge conflics
if [[ -n $CONFLICTS ]]; then
conflicts=`git diff --cached --name-only -G'((<<<<<< HEAD)|(\+======)|(\+>>>>>>))'`
if [ -n "$conflicts" ]; then
echo "Unresolved merge conflicts in this commit:"
echo $conflicts
fi
fi
# Something went wrong
if [[ -n "$conflicts" ]]; then
echo
echo "Commit with '-n' to bypass checks"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment