Permalinks in feature branches on forks should fallback to upstream main for unmodified lines

未关闭
#7,983 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
github, typescript, vscode

调研方向

先检查与 permalink 相关的逻辑以及 issue 中提到的 build/filters.js 示例,然后查找涵盖 fork 和功能分支链接的测试。定义 upstream 默认分支或已配置分支的优先级,并验证未修改的行使用 upstream 链接,而修改过的行保留 fork 链接;issue 未指出任何现有测试或入口点。

由索引模型根据 Issue 内容生成。

描述

feature-request

Problem

Referencing prior fix in PR #1816: Permalinks generated from feature branches on forks do not fallback to upstream main, even for lines that are completely unmodified. This harms canonical link-sharing because:

  1. Links to feature branches break when the branch is deleted (common after PR merge)
  2. Recipients may not have access to fork repositories
  3. The same code exists in upstream main but the link doesn't redirect there

Current Behavior

When creating a permalink from a feature branch on a fork:

  • The link points to: fork/repo/blob/feature-branch/file.ext#L123
  • No fallback occurs even if line 123 is identical in upstream main
  • Link becomes invalid after branch deletion

Proposed Enhancement

Extend the permalink generation logic to:

  1. Check if the referenced lines exist unchanged in upstream main
  2. If unchanged, generate permalink to upstream main instead
  3. Fall back to checking other long-lived branches if not in main
  4. Only use feature branch permalink if code is actually modified

main here be substituted for any default branches, or custom list thereof user can config for reference in order of prefernce
ie main/master/release-5/release-4 whereby main is preferred, but if snippet only exists in a release branch, not main, release branch in upstream is still preferred vs fork link, since it affects ability to paste into upstream github and getting content previews.

ie. https://github.com/microsoft/vscode-pull-request-github/blob/45d42a8efb0d9ba5bbf9810dcb78ba865004f67c/build/filters.js#L14

vs

https://github.com/fork/vscode-pull-request-github/blob/45d42a8efb0d9ba5bbf9810dcb78ba865004f67c/build/filters.js#L14

Context Summary

Aspect Current State Proposed State
Fork feature branch (unchanged code) Links to fork/branch Links to upstream/main
Fork feature branch (changed code) Links to fork/branch Links to fork/branch
After branch deletion Link breaks Link still works
Accessibility Fork access required Public upstream access

Benefits

  • More resilient permalink sharing
  • Better canonical link behavior
  • Reduced broken links after PR merges
  • Improved accessibility for external collaborators

This would make permalinks more useful for documentation, issue references, and knowledge sharing.

related: https://github.com/microsoft/vscode-pull-request-github/issues/1781

主要语言
TypeScript
星标
2.6k
派生
796
平均合并
1 天 4 小时
30 天内合并 PR
46

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-pull-request-github 的其他 Issue

查看 microsoft/vscode-pull-request-github 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。