Skip to content

prevent-link-loss - Handle two-dot diff (range) links#9696

Merged
fregante merged 1 commit into
refined-github:mainfrom
tyrann0us:prevent-link-loss-range-diff
Jun 4, 2026
Merged

prevent-link-loss - Handle two-dot diff (range) links#9696
fregante merged 1 commit into
refined-github:mainfrom
tyrann0us:prevent-link-loss-range-diff

Conversation

@tyrann0us

Copy link
Copy Markdown
Contributor

What this fixes

prevent-link-loss only matched the first commit of a two-dot diff (range) link of the form /pull/N/changes/SHA1..SHA2, leaving ..SHA2 dangling outside the generated Markdown link.

For example:

https://github.com/refined-github/refined-github/pull/6954/changes/32d1c8b2e1b6971709fe273cfdd1f959b51e8d85..5d28ba424368606c7b241840cf4386f23ce66ec3

was converted to:

32d1c8b (#6954)..5d28ba424368606c7b241840cf4386f23ce66ec3

It now produces the full range:

32d1c8b..5d28ba4 (#6954)

prCommitPathnameRegex now optionally captures the second SHA; single-commit links are unaffected (the group is optional). Unit tests added for the range form, idempotency, Markdown-link skipping, and the "this PR" branch.

1. Related issue

No existing issue.

2. Pages affected/tested

Any comment field with a rich-text editor (issue/PR comments, reviews, PR body).

Disclosure: I asked Claude Opus 4.8 to fix the issue and write the tests, but did the rest (this PR description, etc.) manually.

PR commit/changes links of the form `/pull/N/changes/SHA1..SHA2` were only
matched up to SHA1, leaving `..SHA2` outside the generated Markdown link.
Extend `prCommitPathnameRegex` to optionally capture the second SHA and
render it as `SHA1..SHA2` in the replacement.
@tyrann0us tyrann0us marked this pull request as ready for review June 4, 2026 07:07
@fregante fregante added the bug label Jun 4, 2026

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two prevent-link-loss bugfix PRs in an hour? Is it Christmas already? Dankiii

@fregante fregante merged commit c867005 into refined-github:main Jun 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants