mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 05:15:45 +07:00
[IMP] runbot: commit message dep param.
A prototype of feature was added some times a go. No really tested, this commit improves parmater format and makes dependency closest_branch_id not required since a repo/sha is all we need.
This commit is contained in:
parent
46a7362d18
commit
626f454d8b
@ -211,12 +211,12 @@ class runbot_build(models.Model):
|
|||||||
last_commit = params['dep'][repo_name] # not name
|
last_commit = params['dep'][repo_name] # not name
|
||||||
if last_commit:
|
if last_commit:
|
||||||
match_type = 'params'
|
match_type = 'params'
|
||||||
build_closets_branch = False
|
build_closet_branch = False
|
||||||
message = 'Dependency for repo %s defined in commit message' % (repo_name)
|
message = 'Dependency for repo %s defined in commit message' % (repo_name)
|
||||||
else:
|
else:
|
||||||
(build_closets_branch, match_type) = build_id.branch_id._get_closest_branch(extra_repo.id)
|
(build_closet_branch, match_type) = build_id.branch_id._get_closest_branch(extra_repo.id)
|
||||||
closest_name = build_closets_branch.name
|
closest_name = build_closet_branch.name
|
||||||
closest_branch_repo = build_closets_branch.repo_id
|
closest_branch_repo = build_closet_branch.repo_id
|
||||||
last_commit = closest_branch_repo._git_rev_parse(closest_name)
|
last_commit = closest_branch_repo._git_rev_parse(closest_name)
|
||||||
message = 'Dependency for repo %s defined from closest branch %s' % (repo_name, closest_name)
|
message = 'Dependency for repo %s defined from closest branch %s' % (repo_name, closest_name)
|
||||||
try:
|
try:
|
||||||
@ -230,7 +230,7 @@ class runbot_build(models.Model):
|
|||||||
dep_create_vals.append({
|
dep_create_vals.append({
|
||||||
'build_id': build_id.id,
|
'build_id': build_id.id,
|
||||||
'dependecy_repo_id': extra_repo.id,
|
'dependecy_repo_id': extra_repo.id,
|
||||||
'closest_branch_id': build_closets_branch.id,
|
'closest_branch_id': build_closet_branch and build_closet_branch.id,
|
||||||
'dependency_hash': last_commit,
|
'dependency_hash': last_commit,
|
||||||
'match_type': match_type,
|
'match_type': match_type,
|
||||||
})
|
})
|
||||||
@ -265,7 +265,6 @@ class runbot_build(models.Model):
|
|||||||
FROM runbot_build_dependency as DUPLIDEPS
|
FROM runbot_build_dependency as DUPLIDEPS
|
||||||
JOIN runbot_build_dependency as BUILDDEPS
|
JOIN runbot_build_dependency as BUILDDEPS
|
||||||
ON BUILDDEPS.dependency_hash = DUPLIDEPS.dependency_hash
|
ON BUILDDEPS.dependency_hash = DUPLIDEPS.dependency_hash
|
||||||
--AND BUILDDEPS.closest_branch_id = DUPLIDEPS.closest_branch_id -- only usefull if we are affraid of hash collision in different branches
|
|
||||||
AND BUILDDEPS.build_id = %s
|
AND BUILDDEPS.build_id = %s
|
||||||
AND DUPLIDEPS.build_id in %s
|
AND DUPLIDEPS.build_id in %s
|
||||||
GROUP BY DUPLIDEPS.build_id
|
GROUP BY DUPLIDEPS.build_id
|
||||||
@ -381,7 +380,7 @@ class runbot_build(models.Model):
|
|||||||
pass # todo remove this try catch and make correct patch for _git
|
pass # todo remove this try catch and make correct patch for _git
|
||||||
params = defaultdict(lambda: defaultdict(str))
|
params = defaultdict(lambda: defaultdict(str))
|
||||||
if message:
|
if message:
|
||||||
regex = re.compile(r'^[\t ]*dep=([A-Za-z0-9\-_]+/[A-Za-z0-9\-_]+):([0-9A-Fa-f\-]*) *(#.*)?$', re.M) # dep:repo:hash #comment
|
regex = re.compile(r'^[\t ]*Runbot-dependency: ([A-Za-z0-9\-_]+/[A-Za-z0-9\-_]+):([0-9A-Fa-f\-]*) *(#.*)?$', re.M) # dep:repo:hash #comment
|
||||||
for result in re.findall(regex, message):
|
for result in re.findall(regex, message):
|
||||||
params['dep'][result[0]] = result[1]
|
params['dep'][result[0]] = result[1]
|
||||||
return params
|
return params
|
||||||
@ -389,7 +388,7 @@ class runbot_build(models.Model):
|
|||||||
def _copy_dependency_ids(self):
|
def _copy_dependency_ids(self):
|
||||||
return [(0, 0, {
|
return [(0, 0, {
|
||||||
'match_type': dep.match_type,
|
'match_type': dep.match_type,
|
||||||
'closest_branch_id': dep.closest_branch_id.id,
|
'closest_branch_id': dep.closest_branch_id and dep.closest_branch_id.id,
|
||||||
'dependency_hash': dep.dependency_hash,
|
'dependency_hash': dep.dependency_hash,
|
||||||
'dependecy_repo_id': dep.dependecy_repo_id.id,
|
'dependecy_repo_id': dep.dependecy_repo_id.id,
|
||||||
}) for dep in self.dependency_ids]
|
}) for dep in self.dependency_ids]
|
||||||
|
@ -7,7 +7,7 @@ class RunbotBuildDependency(models.Model):
|
|||||||
build_id = fields.Many2one('runbot.build', 'Build', required=True, ondelete='cascade', index=True)
|
build_id = fields.Many2one('runbot.build', 'Build', required=True, ondelete='cascade', index=True)
|
||||||
dependecy_repo_id = fields.Many2one('runbot.repo', 'Dependency repo', required=True, ondelete='cascade')
|
dependecy_repo_id = fields.Many2one('runbot.repo', 'Dependency repo', required=True, ondelete='cascade')
|
||||||
dependency_hash = fields.Char('Name of commit', index=True)
|
dependency_hash = fields.Char('Name of commit', index=True)
|
||||||
closest_branch_id = fields.Many2one('runbot.branch', 'Branch', required=True, ondelete='cascade')
|
closest_branch_id = fields.Many2one('runbot.branch', 'Branch', ondelete='cascade')
|
||||||
match_type = fields.Char('Match Type')
|
match_type = fields.Char('Match Type')
|
||||||
|
|
||||||
def _get_repo(self):
|
def _get_repo(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user