Skip to content

Point "timemachine links" in comments to the correct branch #1953

Closed

Description

@fregante

Extend this feature: #1863


That feature adds a permalink next to each file/directory link that doesn't point to a commit. For example this link:

https://github.com/sindresorhus/refined-github/blob/master/license

If the license file is deleted, this link will become a 404, but its permalink (https://github.com/sindresorhus/refined-github/blob/49f57bec555c693d9590696f0773087aeb741d48/license) will keep working.


The limitation of the feature is that the generated permalink will always point to the default branch, even if the link is:

https://github.com/sindresorhus/refined-github/blob/some-other-branch/license

This is because

  • we can't tell whether some-other-branch is really a branch or a tag without making an API request for each link
  • the way permalinks are generated is by appending @datetime to the reference, but tag@datetime will fail

I can think of two solutions for this:

  • Find out whether each reference is a tag, and if it is, don't add the permalink;
    this probably means find each user/repo#reference and asking the API if there's a tag with that name.
  • Find out the latest commit of each link, and maybe we'll also find out the above;
    maybe the API accepts queries like reference@datetime and that will tell the real commit it points to and maybe fail on tags (with this, the resulting permalink is cleaner but it's probably harder to implement)

API v4 allows multiple queries in a single HTTP request; you can see how this is done in show-names and pr-branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions