#!/usr/bin/env python

import fedmsg
import os
import sys

# Read in all the rev information git-receive-pack hands us.
lines = [line.split() for line in sys.stdin.readlines()]

# Guess the repository name from the location of this file.
# Alternatively, we might use os.getcwd() to get the pwd.
#repo_name = os.path.abspath(__file__).split(os.path.sep)[-3]

# For now, we raise the following exception until the above line is either
# commented out or re-written to make sense for deployment.
raise NotImplementedError


print "Emitting a message to the fedmsg bus."
fedmsg.send_message(
    topic="%s.receive" % repo_name,
    modname="git",
    msg=dict(revs=lines),
)
