2015-02-06 09:50:31 +07:00
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
import glob
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
import openerp
|
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class runbot_build(openerp.models.Model):
|
|
|
|
_inherit = "runbot.build"
|
|
|
|
|
|
|
|
def job_15_check_cla(self, cr, uid, build, lock_path, log_path):
|
2015-02-09 09:56:19 +07:00
|
|
|
cla_glob = glob.glob(build.path("doc/cla/*/*.md"))
|
2015-02-06 09:50:31 +07:00
|
|
|
if cla_glob:
|
2015-02-09 09:56:19 +07:00
|
|
|
cla = ''.join(open(f).read() for f in cla_glob)
|
2015-02-06 09:50:31 +07:00
|
|
|
cla = cla.lower()
|
2015-02-09 09:56:19 +07:00
|
|
|
cla = cla.decode('utf-8')
|
2015-02-06 09:50:31 +07:00
|
|
|
mo = re.search('[^ <@]+@[^ @>]+', build.author_email or '')
|
|
|
|
state = "failure"
|
|
|
|
if mo:
|
|
|
|
email = mo.group(0).lower()
|
|
|
|
if re.match('.*(odoo|openerp|tinyerp).com$',email):
|
|
|
|
state = "success"
|
2015-02-09 09:56:19 +07:00
|
|
|
if cla.find(email) != -1:
|
2015-02-06 09:50:31 +07:00
|
|
|
state = "success"
|
2015-02-09 09:56:19 +07:00
|
|
|
_logger.info('CLA build:%s email:%s result:%s', build.dest, email, state)
|
2015-02-06 09:50:31 +07:00
|
|
|
status = {
|
|
|
|
"state": state,
|
|
|
|
"target_url": "http://www.odoo.com/sign-cla",
|
2015-02-07 23:31:14 +07:00
|
|
|
"description": "%s Odoo CLA signature check" % build.author,
|
2015-02-06 09:50:31 +07:00
|
|
|
"context": "legal/cla"
|
|
|
|
}
|
2015-02-09 09:56:19 +07:00
|
|
|
build._log('check_cla', 'CLA %s' % state)
|
2015-02-06 09:50:31 +07:00
|
|
|
build.repo_id.github('/repos/:owner/:repo/statuses/%s' % build.name, status, ignore_errors=True)
|
|
|
|
# 0 is myself, -1 is everybody else, -2 nothing
|
|
|
|
return -2
|
|
|
|
|