feat(phabricator): add ChangeID entity for parsing phab:// URIs#161
Merged
Conversation
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>
There was a problem hiding this comment.
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(), andRevision()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.
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>
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>
behinddwalls
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testIssues