Skip to content

Commit

Permalink
add compatibility field for landing path
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzeid committed May 9, 2023
1 parent 7eb89c6 commit ecd2abe
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions landoapi/models/landing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@ class LandingJob(Base):
def landing_path(self) -> list[tuple[int, int]]:
return [(revision.revision_id, revision.diff_id) for revision in self.revisions]

@property
def landing_path_compat(self):
"""Return landing path based on associated revisions or legacy fields."""
if self.revisions:
return [
{
"revision_id": "D{}".format(revision_id),
"diff_id": diff_id,
}
for revision_id, diff_id in self.landing_path
]
else:
return [
{"revision_id": "D{}".format(r), "diff_id": self.revision_to_diff_id[r]}
for r in self.revision_order
]

@property
def head_revision(self) -> str:
"""Human-readable representation of the branch head's Phabricator revision ID."""
Expand Down Expand Up @@ -313,13 +330,7 @@ def serialize(self) -> dict[str, Any]:
return {
"id": self.id,
"status": self.status.value,
"landing_path": [
{
"revision_id": "D{}".format(revision.revision_id),
"diff_id": revision.diff_id,
}
for revision in self.revisions
],
"landing_path": self.landing_path_compat,
"error_breakdown": self.error_breakdown,
"details": (
self.error or self.landed_commit_id
Expand Down

0 comments on commit ecd2abe

Please sign in to comment.