Skip to content

feat(phabricator): add ChangeID entity for parsing phab:// URIs#161

Merged
behinddwalls merged 3 commits into
mainfrom
wua/support-phab-change-items
May 28, 2026
Merged

feat(phabricator): add ChangeID entity for parsing phab:// URIs#161
behinddwalls merged 3 commits into
mainfrom
wua/support-phab-change-items

Conversation

@albertywu
Copy link
Copy Markdown
Contributor

@albertywu albertywu commented May 28, 2026

Summary

Mirrors entity/github.ChangeID with a Phabricator-shaped identifier: phab://D{revision_id}/{diff_id}.

Parser validates scheme, the "D" prefix on the revision segment, positive integer revision/diff IDs, and exact
segment count. Adds a Revision() accessor that returns the canonical "D{n}" form used everywhere in the Phabricator UI and CLI.

No downstream consumers yet — changeprovider/mergechecker/pusher wiring will come in follow-up PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Test Plan

make test

Issues

Mirrors entity/github.ChangeID with a Phabricator-shaped identifier:
phab://D{revision_id}/{diff_id}. Parser validates scheme, the "D" prefix
on the revision segment, positive integer revision/diff IDs, and exact
segment count. Adds a Revision() accessor that returns the canonical
"D{n}" form used everywhere in the Phabricator UI and CLI.

No downstream consumers yet — changeprovider/mergechecker/pusher wiring
will come in follow-up PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 28, 2026 05:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new entity/phabricator package for parsing and representing Phabricator change IDs in the form phab://D{revision_id}/{diff_id}, mirroring the existing GitHub ChangeID entity pattern.

Changes:

  • Introduces ChangeID, ParseChangeID, String(), and Revision() for Phabricator URIs.
  • Adds unit tests for valid parsing, parser error branches, revision formatting, and round-trip stringification.
  • Adds Bazel targets for the new package and tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
entity/phabricator/change_id.go Implements Phabricator ChangeID parsing and formatting.
entity/phabricator/change_id_test.go Adds tests for the new parser and helper methods.
entity/phabricator/BUILD.bazel Adds Bazel build/test targets for the new package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread entity/phabricator/change_id.go Outdated
Comment thread entity/phabricator/change_id.go Outdated
Replace ~25 lines of per-branch checks (empty / prefix / digits-after-D /
non-numeric / non-positive) with two precompiled patterns:
  - revisionPattern: ^D([1-9]\d*)$
  - diffPattern:     ^[1-9]\d*$

One error per segment instead of four/three. Also rejects leading-zero
forms like phab://D01/02 which previously parsed silently and broke the
round-trip with String(). Adds two test cases covering the new strictness.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread entity/phabricator/change_id.go Outdated
Comment thread entity/phabricator/change_id.go Outdated
The regex pre-filter guarantees only [1-9]\d* reaches strconv.Atoi, but
unbounded digit runs can still overflow int64 — and silently discarding
that error landed RevisionID/DiffID at 0, producing a "valid" ChangeID
that the regex was specifically designed to forbid. Check the Atoi error
and return it. Adds test cases covering 20-digit overflow inputs for
both segments.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@albertywu albertywu marked this pull request as ready for review May 28, 2026 14:22
@albertywu albertywu requested review from a team and sbalabanov as code owners May 28, 2026 14:22
@behinddwalls behinddwalls added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit b252cd6 May 28, 2026
14 checks passed
@github-actions github-actions Bot deleted the wua/support-phab-change-items branch May 28, 2026 18:15
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.

3 participants