2015-02-06 09:50:31 +07:00
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
import glob
|
2018-03-14 17:07:55 +07:00
|
|
|
import io
|
2015-02-06 09:50:31 +07:00
|
|
|
import logging
|
|
|
|
import re
|
|
|
|
|
2018-02-28 16:31:05 +07:00
|
|
|
from odoo import models
|
2015-02-06 09:50:31 +07:00
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
2018-02-28 16:31:05 +07:00
|
|
|
|
|
|
|
class runbot_build(models.Model):
|
2015-02-06 09:50:31 +07:00
|
|
|
_inherit = "runbot.build"
|
|
|
|
|
2018-02-28 16:31:05 +07:00
|
|
|
def _job_05_check_cla(self, build, lock_path, log_path):
|
2017-04-27 19:28:01 +07:00
|
|
|
cla_glob = glob.glob(build._path("doc/cla/*/*.md"))
|
2015-02-06 09:50:31 +07:00
|
|
|
if cla_glob:
|
2018-02-28 16:31:05 +07:00
|
|
|
description = "%s Odoo CLA signature check" % build.author
|
2015-02-06 09:50:31 +07:00
|
|
|
mo = re.search('[^ <@]+@[^ @>]+', build.author_email or '')
|
|
|
|
state = "failure"
|
|
|
|
if mo:
|
|
|
|
email = mo.group(0).lower()
|
2015-02-17 23:22:28 +07:00
|
|
|
if re.match('.*@(odoo|openerp|tinyerp)\.com$', email):
|
2015-02-06 09:50:31 +07:00
|
|
|
state = "success"
|
2018-02-28 16:31:05 +07:00
|
|
|
else:
|
|
|
|
try:
|
2018-03-14 17:07:55 +07:00
|
|
|
cla = ''.join(io.open(f,encoding='utf-8').read() for f in cla_glob)
|
2018-02-28 16:31:05 +07:00
|
|
|
if cla.lower().find(email) != -1:
|
|
|
|
state = "success"
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
description = 'Invalid CLA encoding (must be utf-8)'
|
|
|
|
_logger.info('CLA build:%s email:%s result:%s', build.dest, email, state)
|
2015-02-06 09:50:31 +07:00
|
|
|
status = {
|
|
|
|
"state": state,
|
2015-02-17 23:23:52 +07:00
|
|
|
"target_url": "https://www.odoo.com/sign-cla",
|
2018-02-28 16:31:05 +07:00
|
|
|
"description": description,
|
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)
|
2017-04-27 19:28:01 +07:00
|
|
|
build.repo_id._github('/repos/:owner/:repo/statuses/%s' % build.name, status, ignore_errors=True)
|
2015-02-06 09:50:31 +07:00
|
|
|
# 0 is myself, -1 is everybody else, -2 nothing
|
|
|
|
return -2
|