# HG changeset patch # User Marcin Kuzminski # Date 2020-08-03 09:15:04 # Node ID 0186d5e239336c611bc33933c82a9ed1f8e576d8 # Parent 3db6401f0ec0b62c57c5ac1273c75a5bbe4b8911 pull-requests: properly save merge failure metadata. Before this change when reference errors were saved the de-serialization lost some of the attributes resulting in bad formatting of merge failure messages. diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -4134,6 +4134,23 @@ class _PullRequestBase(BaseModel): return json.dumps(self.reviewer_data) @property + def last_merge_metadata_parsed(self): + metadata = {} + if not self.last_merge_metadata: + return metadata + + if hasattr(self.last_merge_metadata, 'de_coerce'): + for k, v in self.last_merge_metadata.de_coerce().items(): + if k in ['target_ref', 'source_ref']: + metadata[k] = Reference(v['type'], v['name'], v['commit_id']) + else: + if hasattr(v, 'de_coerce'): + metadata[k] = v.de_coerce() + else: + metadata[k] = v + return metadata + + @property def work_in_progress(self): """checks if pull request is work in progress by checking the title""" title = self.title.upper() diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -1600,7 +1600,7 @@ class PullRequestModel(BaseModel): 'source_ref': pull_request.source_ref_parts, } if pull_request.last_merge_metadata: - metadata.update(pull_request.last_merge_metadata) + metadata.update(pull_request.last_merge_metadata_parsed) if not possible and target_ref.type == 'branch': # NOTE(marcink): case for mercurial multiple heads on branch