From e40e814b90bf7b5570bf6ae8c2d15c409348eb9f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 26 Aug 2019 16:25:16 +0200 Subject: [PATCH] [IMP] runbot_merge: show heads on stagings Stagings have a "statuses" field which was shown but useless (as it's a binary), they also have a "heads" field which only provides a mapping of repository names to commits. This change provides the staging heads as a commits m2m. Fixes #178 --- runbot_merge/models/pull_requests.py | 3 ++- runbot_merge/views/mergebot.xml | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 44618c70..0634d7bb 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1265,6 +1265,7 @@ class Stagings(models.Model): # seems simpler than adding yet another indirection through a model heads = fields.Char(required=True, help="JSON-encoded map of heads, one per repo in the project") + head_ids = fields.Many2many('runbot_merge.commit', compute='_compute_statuses') statuses = fields.Binary(compute='_compute_statuses') @@ -1279,7 +1280,7 @@ class Stagings(models.Model): head: repo for repo, head in json.loads(st.heads).items() if not repo.endswith('^') } - commits = Commits.search([('sha', 'in', list(heads.keys()))]) + commits = st.head_ids = Commits.search([('sha', 'in', list(heads.keys()))]) st.statuses = [ ( heads[commit.sha], diff --git a/runbot_merge/views/mergebot.xml b/runbot_merge/views/mergebot.xml index b1af5357..024a01de 100644 --- a/runbot_merge/views/mergebot.xml +++ b/runbot_merge/views/mergebot.xml @@ -201,11 +201,18 @@ - - - + + + + + + + + + +