Skip to content

refactor(git): de-duplicate Bitbucket PR/issue field mappings - #1780

Merged
gfargo-horizon-agent[bot] merged 2 commits into
mainfrom
agent/coco-957-coco-1715-high-bitbucketlistdata-ts-fiel
Jul 21, 2026
Merged

refactor(git): de-duplicate Bitbucket PR/issue field mappings#1780
gfargo-horizon-agent[bot] merged 2 commits into
mainfrom
agent/coco-957-coco-1715-high-bitbucketlistdata-ts-fiel

Conversation

@gfargo-horizon-agent

@gfargo-horizon-agent gfargo-horizon-agent Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What

De-duplicates the Bitbucket raw→view-model field mapping in src/git/bitbucketListData.ts, which previously existed three times for PRs and twice for issues.

Why

Closes #1715
Plane: OSS-957

parsePullRequests/parseIssues were exercised only by unit tests, while getBitbucketPullRequestList/getBitbucketIssueList paginated via fetchAllPages and re-mapped inline — so a mapping fix applied to one copy could silently miss the others, and the tests wouldn't catch it.

How

  • Extracted mapPullRequestItem/mapIssueItem as the single source of truth for raw→view-model mapping.
  • Extracted prSharedFields for the 11 fields common to PullRequestListItem and PullRequestInfo.
  • parsePullRequests/parseIssues now just call parsePage(...).values.map(mapX).
  • getBitbucketPullRequestList/getBitbucketIssueList now map fetchAllPages results through the same mappers instead of inline closures.
  • prToPullRequestInfo now reuses prSharedFields + body instead of a third hand-written copy.
  • No behavior change: normalizeState, nicknameOf, nicknamesOf, etc. all unchanged; sanitize* still applied at call sites.

Testing

  • build passes
  • tests pass (existing bitbucketListData.test.ts suite, 33 tests, now exercises production mapping code)
  • lint clean
  • CI: pending

🤖 Generated by the harbor agent loop. Reviewed by a human before merge.

Closes #1715

Extract mapPullRequestItem/mapIssueItem (and a prSharedFields helper for
prToPullRequestInfo) so the raw->view-model mapping exists once instead of
three near-identical copies. getBitbucketPullRequestList/getBitbucketIssueList
now map fetchAllPages results through the same mappers the unit tests
exercise via parsePullRequests/parseIssues, closing the gap where tested
code and production code had diverged.

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Agent review (sonnet) — LGTM

REVIEW: LGTM
RESOLVES: full

The PR extracts mapPullRequestItem/mapIssueItem/prSharedFields exactly per the plan, wires getBitbucketPullRequestList/getBitbucketIssueList/parsePullRequests/parseIssues/prToPullRequestInfo through them, and keeps the __test export delegating to parsePullRequests/parseIssues so existing tests now exercise the real production mapping path. Diff is scoped to a single file, all mapping logic is byte-identical to the prior triplicated code, and tests/lint/typecheck pass locally.

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Agent re-review (sonnet, delta) — LGTM

REVIEW: LGTM
RESOLVES: full

The revise consolidates the triplicated PR mapping into prSharedFields/mapPullRequestItem and the duplicated issue mapping into mapIssueItem, with production paths (getBitbucketPullRequestList/getBitbucketIssueList/prToPullRequestInfo) now routed through the same functions the tests exercise via parsePullRequests/parseIssues. Tests, lint, and typecheck all pass with no behavioral changes or scope creep detected.

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Agent re-review (sonnet, delta) — LGTM

REVIEW: LGTM
RESOLVES: full

The revise correctly extracts mapPullRequestItem/mapIssueItem/prSharedFields and routes all three call sites (parsePullRequests/parseIssues, getBitbucketPullRequestList/getBitbucketIssueList, prToPullRequestInfo) through them, eliminating the triplicated mapping and making the existing unit tests exercise the real production mapping code. Tests (43/43) and typecheck pass with no new issues introduced.

…715-high-bitbucketlistdata-ts-fiel

# Conflicts:
#	src/git/bitbucketListData.ts

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Agent re-review (sonnet, delta) — LGTM

REVIEW: LGTM
RESOLVES: full

The only change since the last review is a merge-from-main commit that resolved a conflict in bitbucketListData.ts; comparing origin/main to HEAD shows it's a clean rebase of the dedup refactor (prSharedFields/mapPullRequestItem/mapIssueItem) on top of main's independently-added @me-resolution, bbqlQuote escaping, and paginate helper, with nothing dropped or duplicated back in. No new production or test regressions were introduced.

@gfargo-horizon-agent
gfargo-horizon-agent Bot merged commit 5d48f21 into main Jul 21, 2026
14 checks passed
@gfargo-horizon-agent
gfargo-horizon-agent Bot deleted the agent/coco-957-coco-1715-high-bitbucketlistdata-ts-fiel branch July 21, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[High] bitbucketListData.ts: field mappings written 3x, and the tested parsers are dead in production

0 participants