sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Add "view file before commit/PR" #3289

OliverJAsh posted onGitHub

<!-- 1. Make sure your requested feature makes sense for Refined GitHub: https://github.com/sindresorhus/refined-github/issues/2960 2. Include a full URL where the feature should appear. -->

When viewing a commit page, GitHub provides a link to view each file. The link points to the file at the current commit. Example.

<img width="300" src="https://user-images.githubusercontent.com/921609/85848863-d0dd4080-b7a1-11ea-8a98-c257128d13b9.png" />

However, sometimes we want to view the version of a file before the commit was made.

For the longest time I have been doing this manually, by clicking "view file" and then editing the URL to add a ^ at the end of the commit (to reference the parent commit).

It would be very useful if this was added as a link in the menu, so we don't have to resort to hacking the URL like this.

This would also be useful in PRs, where GitHub similarly shows a "view file" link for each file in the diff. Sometimes we want to view the version of a file before all of the commits in this PR.

<img width="300" src="https://user-images.githubusercontent.com/921609/85848997-0f72fb00-b7a2-11ea-9020-3fce80d604db.png" />


For the longest time I have been doing this manually, by clicking "view file" and then editing the URL to add a ^ at the end of the commit (to reference the parent commit).

What about an alt-click to go to the parent commit?

Sometimes we want to view the version of a file before all of the commits in this PR.

I think this would make sense as its own button. Also it would need to handle files created with this pr.

posted by yakov116 almost 5 years ago

@yakov116 That would work, although it's less discoverable.

posted by OliverJAsh almost 5 years ago

I find the lack of this really annoying. Is it possible that there’s no path to that page? I think it’s at least 3 clicks/pages away, which isn’t good.

Suggestions welcome. Alt-click isn’t ideal in this case.

posted by fregante almost 5 years ago

Is it possible that there’s no path to that page?

Isn't it just as simple as replacing the commit param in the URL with the following?

  • For commits, ${COMMIT}^
  • For PRs, the name of the base branch
posted by OliverJAsh almost 5 years ago

My question was: how is it possible that GitHub didn’t add this feature? Is there any other non-obvious way to reach that page?

I’m not talking about “how to fix it,” because as you said it’s pretty easy.

posted by fregante almost 5 years ago

How about this?

image

posted by yakov116 almost 5 years ago

@OliverJAsh Where do you expect to see the commit on the base branch or the head branch?

posted by yakov116 almost 5 years ago

On the base branch/commit I think? (The existing "view file" points to the head branch/commit.)

posted by OliverJAsh almost 5 years ago

This is possible:

Made by:

  1. Wrap the existing .dropdown-item link into .d-flex
  2. Add identical link but use icon instead of text
  3. width: min-content; padding-left: 8px
<div class="d-flex">
  {previousLink}
  <a {… previousLink attrs} style="padding-left: 8px !important;width: min-content;">
    <GitHistoryIcon/>
  </a>
</div>

This should be applied to regular commits as well.

If a file is deleted by the current commit, the "View file" already points to the old commit, so in that case perhaps we should add the icon inside the existing link; this would indicate that the link points to the old commit.

posted by fregante over 4 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests