isaacs / github

Just a place to track issues and feature requests that I have for github
2.21k stars 129 forks source link

Add "view file before commit/PR" #1826

Open OliverJAsh opened 4 years ago

OliverJAsh commented 4 years ago

Copied from https://github.com/sindresorhus/refined-github/issues/3289

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

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.

botatoes commented 3 years ago

Hi @OliverJAsh I'm a PM at GitHub. Was wondering if you could explain your use case a bit more? Are you looking for more than what the split view is showing?

OliverJAsh commented 3 years ago

Hey! I have a few different use cases, but the one that jumps to mind immediately is this:

When I'm viewing a PR, sometimes I want to copy a section of code before it changed. In the diff view this is difficult because

I have other use cases but I can't remember what they are right now. When I remember I'll try to drop a comment here.

botatoes commented 3 years ago

@OliverJAsh We just (super) recently shipped ability to copy only one side of the diff. Would that solve your problem?

OliverJAsh commented 3 years ago

@botatoes I just tested it but it only works in split view right? A lot of the time I'm reviewing in unified view.

Furthermore we still have these problems in split view:

  • the selection could include comments, and some parts of the code are collapsed so they are not easy to select

Nothing can beat a raw version of the file.

botatoes commented 3 years ago

Cool, thanks for clarifying :) I'll take it back to the team to discuss priority.

OliverJAsh commented 3 years ago

@botatoes I have another use case! This one comes up a lot.

I am running through a git blame through the GitHub UI. I am trying to trace a single line back to when it was originally added. The "View blame prior to this change" is very useful, until you reach a commit where the code was moved from one file to another. At this point, I have to view the commit where the code was moved so I can find where it was moved from. Once I've found where it was moved from, I can jump back into the blame view and continue my search.

The tricky part is this: the commit shows me where the code was moved from, but it's very difficult to perform a blame on the file before the code was moved.

If the UI allowed me to "view file before commit/PR" as I suggested in my OP, then this wouldn't be so difficult.

The issue occurs when a whole file has been moved or just a small subset of the file has been moved.