Skip to content

Instantly share code, notes, and snippets.

@co3k
Created July 8, 2013 13:03
Show Gist options
  • Save co3k/5948590 to your computer and use it in GitHub Desktop.
Save co3k/5948590 to your computer and use it in GitHub Desktop.
Git pre-push hook script to display confirmation of the push action
#!/usr/bin/env python
import sys, os
info = sys.stdin.read().strip().split(" ")
range = ""
if info:
range = "{}..{}".format(info[3], info[1])
sys.stdin = open('/dev/tty')
print "Repository: {} ({})".format(sys.argv[1], sys.argv[2])
print "Branch: {} -> {}".format(info[0], info[2])
print "Range: {}".format(range)
print "Log:"
os.system("git log --color --oneline {} | cat ".format(range))
print "\n----"
choice = raw_input("Do you want to continue? [y/N]\n").lower()
if "y" == choice:
sys.exit(0)
else:
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment