Skip to content

Instantly share code, notes, and snippets.

@jboehler
Last active December 14, 2015 12:49
Show Gist options
  • Save jboehler/5089319 to your computer and use it in GitHub Desktop.
Save jboehler/5089319 to your computer and use it in GitHub Desktop.

create ´~/.git_template/hooks/pre-commit´ file

#!/usr/bin/python

import os
import sys

username = os.popen("git config user.name").read()
usermail = os.popen("git config user.email").read()

if username == "" or usermail == "":
    message = "No git user identity found"
    title = "Git Commit Abort"
    os.system("terminal-notifier -message '"+message+"' -title '"+title+"' > /dev/null")
    print '\033[91m' + title+": "+message + '\033[0m'
    print "for ignore this hook on this repository:"
    print "rm "+os.popen("pwd").read().strip(' \t\n\r')+"/.git/hooks/pre-commit"
    exit(1)

install terminal-notifier

sudo gem install terminal-notifier

set git hook template

git config --global init.templatedir '~/.git_template'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment