[FIX] runbot: add missing tree hash

Previous commit introduced commit tree hash, but only when calling
get_commit_infos. This fixes the get_ref and find_new_commit to have
the same infos.
This commit is contained in:
Xavier-Do 2024-04-15 16:35:26 +02:00
parent c70aa57acb
commit d5f6444787
2 changed files with 13 additions and 3 deletions

View File

@ -504,7 +504,7 @@ class Repo(models.Model):
if not self.get_ref_time or get_ref_time > self.get_ref_time:
try:
self._set_ref_time(get_ref_time)
fields = ['refname', 'objectname', 'committerdate:unix', 'authorname', 'authoremail', 'subject', 'committername', 'committeremail']
fields = ['refname', 'objectname', 'committerdate:unix', 'authorname', 'authoremail', 'subject', 'committername', 'committeremail', 'tree']
fmt = "%00".join(["%(" + field + ")" for field in fields])
cmd = ['for-each-ref', '--format', fmt, '--sort=-committerdate', 'refs/*/heads/*']
if any(remote.fetch_pull for remote in self.remote_ids):
@ -537,7 +537,7 @@ class Repo(models.Model):
branches = self.env['runbot.branch'].search([('name', 'in', names), ('remote_id', 'in', self.remote_ids.ids)])
ref_branches = {branch._ref(): branch for branch in branches}
new_branch_values = []
for ref_name, sha, date, author, author_email, subject, committer, committer_email in refs:
for ref_name, *_unused in refs:
if not ref_branches.get(ref_name):
# format example:
# refs/ruodoo-dev/heads/12.0-must-fail
@ -565,7 +565,7 @@ class Repo(models.Model):
"""
self.ensure_one()
for ref_name, sha, date, author, author_email, subject, committer, committer_email in refs:
for ref_name, sha, date, author, author_email, subject, committer, committer_email, tree_hash in refs:
branch = ref_branches[ref_name]
if branch.head_name != sha: # new push on branch
_logger.info('repo %s branch %s new commit found: %s', self.name, branch.name, sha)
@ -577,6 +577,7 @@ class Repo(models.Model):
'committer_email': committer_email,
'subject': subject,
'date': datetime.datetime.fromtimestamp(int(date)),
'tree_hash': tree_hash,
})
branch.head = commit
if not branch.alive:

View File

@ -35,6 +35,15 @@
<span class="badge badge-info" t-esc="s2human(batch.last_update - batch.create_date)"/>
</td>
</tr>
</td>
<tr t-if="more and batch.reference_batch_ids">
<td>Version reference batches (for upgrade)</td>
<td>
<t t-foreach="batch.reference_batch_ids" t-as="reference_batch"/>
<div><a t-attf-href="/runbot/batch/{{reference_batch.id}}"><t t-esc="reference_batch.bundle_id.version_id.name"/> (<t t-esc="reference_batch.id"/>)</a></div>
</td>
</tr>
<tr t-att-class="'bg-info-light' if batch.state=='preparing' else 'bg-success-light' if not any(log.level != 'INFO' for log in batch.log_ids) else 'bg-warning-light'">
<td>Commits</td>
<td>