runbot add author and subject support

This commit is contained in:
Antony Lesuisse 2014-05-28 01:02:02 +02:00
parent 33304c77ec
commit d075d1e8a0
2 changed files with 34 additions and 12 deletions

View File

@ -208,11 +208,21 @@ class runbot_repo(osv.osv):
else: else:
repo.git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*']) repo.git(['fetch', '-p', 'origin', '+refs/heads/*:refs/heads/*'])
repo.git(['fetch', '-p', 'origin', '+refs/pull/*/head:refs/pull/*']) repo.git(['fetch', '-p', 'origin', '+refs/pull/*/head:refs/pull/*'])
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/heads'])
refs = [simplejson.loads(i) for i in out.split('\n') if i] fields = ['refname','objectname','authordate:iso8601','authorname','subject']
out = repo.git(['for-each-ref', '--format', '["%(refname)","%(objectname)","%(authordate:iso8601)"]', '--sort=-committerdate', 'refs/pull']) fmt = "%00".join(["%("+i+")" for i in fields])
refs += [simplejson.loads(i) for i in out.split('\n') if i] out = repo.git(['for-each-ref', '--format', fmt, '--sort=-committerdate', 'refs/heads', 'refs/pull'])
for name, sha, date in refs: out = out.strip()
refs = []
for l in out.split('\n'):
ref = []
for i in l.split('\x00'):
try:
ref.append(i.decode('utf-8'))
except UnicodeDecodeError:
ref.append('')
refs.append(ref)
for name, sha, date, author, subject in refs:
# create or get branch # create or get branch
branch_ids = self.pool['runbot.branch'].search(cr, uid, [('repo_id', '=', repo.id), ('name', '=', name)]) branch_ids = self.pool['runbot.branch'].search(cr, uid, [('repo_id', '=', repo.id), ('name', '=', name)])
if branch_ids: if branch_ids:
@ -228,7 +238,13 @@ class runbot_repo(osv.osv):
build_ids = self.pool['runbot.build'].search(cr, uid, [('branch_id', '=', branch.id), ('name', '=', sha)]) build_ids = self.pool['runbot.build'].search(cr, uid, [('branch_id', '=', branch.id), ('name', '=', sha)])
if not build_ids: if not build_ids:
_logger.debug('repo %s branch %s new build found revno %s', branch.repo_id.name, branch.name, sha) _logger.debug('repo %s branch %s new build found revno %s', branch.repo_id.name, branch.name, sha)
self.pool['runbot.build'].create(cr, uid, {'branch_id': branch.id, 'name': sha}) v = {
'branch_id': branch.id,
'name': sha,
'author': author,
'subject': subject,
}
self.pool['runbot.build'].create(cr, uid, v)
def scheduler(self, cr, uid, ids=None, context=None): def scheduler(self, cr, uid, ids=None, context=None):
for repo in self.browse(cr, uid, ids, context=context): for repo in self.browse(cr, uid, ids, context=context):
@ -391,8 +407,8 @@ class runbot_build(osv.osv):
'dest': fields.function(_get_dest, type='char', string='Dest', readonly=1, store=True), 'dest': fields.function(_get_dest, type='char', string='Dest', readonly=1, store=True),
'domain': fields.function(_get_domain, type='char', string='URL'), 'domain': fields.function(_get_domain, type='char', string='URL'),
'date': fields.datetime('Commit date'), 'date': fields.datetime('Commit date'),
'committer': fields.char('Comitter'), 'author': fields.char('Author'),
'log': fields.text('Commit log'), 'subject': fields.text('Subject'),
'sequence': fields.integer('Sequence'), 'sequence': fields.integer('Sequence'),
'result': fields.char('Result'), # ok, ko 'result': fields.char('Result'), # ok, ko
'pid': fields.integer('Pid'), 'pid': fields.integer('Pid'),

View File

@ -117,8 +117,8 @@
<field name="sequence"/> <field name="sequence"/>
<field name="name"/> <field name="name"/>
<field name="date"/> <field name="date"/>
<field name="committer"/> <field name="author"/>
<field name="log"/> <field name="subject"/>
<field name="port"/> <field name="port"/>
<field name="dest"/> <field name="dest"/>
<field name="state"/> <field name="state"/>
@ -141,7 +141,7 @@
<field name="repo_id"/> <field name="repo_id"/>
<field name="dest"/> <field name="dest"/>
<field name="date"/> <field name="date"/>
<field name="committer"/> <field name="author"/>
<field name="state"/> <field name="state"/>
<field name="port"/> <field name="port"/>
<field name="job"/> <field name="job"/>
@ -340,7 +340,9 @@
<t t-if="bu.state in ['running','done'] and bu.result == 'ok'"><t t-set="klass">success</t></t> <t t-if="bu.state in ['running','done'] and bu.result == 'ok'"><t t-set="klass">success</t></t>
<td t-attf-class="{{klass}}"> <td t-attf-class="{{klass}}">
<t t-call="runbot.build_button"><t t-set="klass">btn-group-sm</t></t> <t t-call="runbot.build_button"><t t-set="klass">btn-group-sm</t></t>
<t t-esc="bu.dest"/><br/> <t t-esc="bu.subject[:24] if bu.subject else ''"/><br/>
<t t-esc="bu.author"/><br/>
<small><t t-esc="bu.dest"/></small><br/>
<t t-call="runbot.build_name"/> <t t-call="runbot.build_name"/>
</td> </td>
</t> </t>
@ -427,6 +429,10 @@
</div> </div>
</div> </div>
</nav> </nav>
<p>
Subject: <t t-esc="build.subject[:24] if build.subject else ''"/><br/>
Author: <t t-esc="build.author"/><br/>
</p>
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<tr> <tr>
<th>Date</th> <th>Date</th>