[FIX] forwardport: fix sourcing on reparenting

When reparenting a commit (mostly when inserting a new forwardport in
an existing chain after a freeze / branch insertion), the new source
should be the source of the new parent (which is likely a not-change
of the source).

This was miscomputed to the root of the new parent, which often
matches but breaks if there was a conflict or a mid-port update,
leading to inconsistent presentation. Nothing critical, just somewhat
annoying.
This commit is contained in:
Xavier Morel 2023-10-31 07:36:10 +01:00
parent f44b0c018e
commit 134ce03053

View File

@ -348,7 +348,8 @@ class PullRequests(models.Model):
})
if vals.get('parent_id') and 'source_id' not in vals:
vals['source_id'] = self.browse(vals['parent_id']).root_id.id
parent = self.browse(vals['parent_id'])
vals['source_id'] = (parent.source_id or parent).id
if vals.get('state') == 'merged':
vals['merge_date'] = fields.Datetime.now()
r = super().write(vals)