Parent: [9ba5e6] (diff)

Child: [24cc5e] (diff)

Download this file

reactors.py    30 lines (24 with data), 875 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import logging
import pylons
from pyforge.lib.decorators import audit, react
from pyforge import model as M
from pyforge.lib import helpers as h
from pyforge.lib import search
log = logging.getLogger(__name__)
@audit('scm.git.init')
def init(routing_key, data):
repo = pylons.c.app.repo
repo.init()
M.Notification.post_user(
pylons.c.user, repo, 'created',
text='Repository %s created' % repo.name)
@react('scm.git.refresh_commit')
def refresh_commit(routing_key, data):
repo = pylons.c.app.repo
hash = data['hash']
log.info('Refresh commit %s', hash)
c_from, c_to = hash.split('..')
for cobj in repo.iter_commits(rev=hash):
aref = cobj.dump_ref()
for ref in search.find_shortlinks(cobj.message):
M.ArtifactReference(ref.artifact_reference).to_artifact().backreferences['git_%s' % hash] = aref