Update our git hook.
With the changes from here: https://github.com/fedora-infra/fedmsg/pull/327
This commit is contained in:
parent
71842302f4
commit
0f660ef5c4
1 changed files with 23 additions and 6 deletions
29
roles/git/hooks/files/post-receive-fedmsg
Normal file → Executable file
29
roles/git/hooks/files/post-receive-fedmsg
Normal file → Executable file
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import os
|
import os
|
||||||
|
import subprocess as sp
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -26,15 +27,19 @@ config['active'] = True
|
||||||
config['endpoints']['relay_inbound'] = config['relay_inbound']
|
config['endpoints']['relay_inbound'] = config['relay_inbound']
|
||||||
fedmsg.init(name='relay_inbound', cert_prefix='scm', **config)
|
fedmsg.init(name='relay_inbound', cert_prefix='scm', **config)
|
||||||
|
|
||||||
|
|
||||||
def revs_between(head, base):
|
def revs_between(head, base):
|
||||||
""" Yield revisions between HEAD and BASE. """
|
""" Yield revisions between HEAD and BASE. """
|
||||||
|
|
||||||
# XXX REALLY, just yield head.
|
# pygit2 can't do a rev-list yet, so we have to shell out.. silly.
|
||||||
# We used to try to navigate the git history and return all the commits in
|
cmd = '/usr/bin/git rev-list %s...%s' % (head.id, base.id)
|
||||||
# between, but we got into infinite loops more than once because git.
|
proc = sp.Popen(cmd.split(), stdout=sp.PIPE, stderr=sp.PIPE, cwd=abspath)
|
||||||
# We could shell out to 'git rev-list head...base', but I'm just not ready
|
stdout, stderr = proc.communicate()
|
||||||
# to do that yet.
|
if proc.returncode != 0:
|
||||||
yield head.id
|
raise IOError('git rev-list failed: %r, err: %r' % (stdout, stderr))
|
||||||
|
|
||||||
|
for line in stdout.strip().split('\n'):
|
||||||
|
yield line.strip()
|
||||||
|
|
||||||
|
|
||||||
def build_stats(commit):
|
def build_stats(commit):
|
||||||
|
@ -62,6 +67,8 @@ def build_stats(commit):
|
||||||
return files, total
|
return files, total
|
||||||
|
|
||||||
|
|
||||||
|
seen = []
|
||||||
|
|
||||||
# Read in all the rev information git-receive-pack hands us.
|
# Read in all the rev information git-receive-pack hands us.
|
||||||
lines = [line.split() for line in sys.stdin.readlines()]
|
lines = [line.split() for line in sys.stdin.readlines()]
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -112,6 +119,16 @@ for line in lines:
|
||||||
|
|
||||||
print "* Publishing information for %i commits" % len(commits)
|
print "* Publishing information for %i commits" % len(commits)
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
|
# Keep track of whether or not we have already published this commit on
|
||||||
|
# another branch or not. It is conceivable that someone could make a
|
||||||
|
# commit to a number of branches, and push them all at the same time.
|
||||||
|
# Make a note in the fedmsg payload so we can try to reduce spam at a
|
||||||
|
# later stage.
|
||||||
|
if commit['rev'] in seen:
|
||||||
|
commit['seen'] = True
|
||||||
|
else:
|
||||||
|
commit['seen'] = False
|
||||||
|
seen.append(commit['rev'])
|
||||||
|
|
||||||
if commit is None:
|
if commit is None:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue