#!/usr/bin/env python

def bail(message):
  print message
  quit()

print "checking for GitPython"

try:
  from git import *
except ImportError:
  bail("Deployment Error: GitPython is not installed.")

repo = Repo('.')

print "making sure repo is clean"
if repo.is_dirty():
  # bail("You have changes in your working directory.\nMake sure your repo is clean before deploying.")
  print "Repo is dirty. but you're developing, so I'll let you do it."

print "checking for gh-pages branch"
if not 'gh-pages' in [branch.name for branch in repo.heads]:
  print "gh-pages branch doesn't exist yet. creating it."
  repo.git.checkout('head', b="gh-pages")
else:
  repo.heads['gh-pages'].checkout()
  print "gh-pages branch exists. checking it out"

print "current branch is now %s" % repo.head.ref.name


print "merge master"
import pdb; pdb.set_trace()

print "compile sass shit"

print "commit the pages repo"

print "push origin"

print "checkout master"

