Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Prefer SHA to branch, give option to right-click in editor, and prefer line numbers #78
This PR introduces 3 changes:
I'm a recovering PHPStorm user, and I've been enjoying VSCode for a couple of weeks now. For all of its problems, PHPStorm had something amazing that I've been missing in VSCode. It had GitHub integration out of the box, and among the other things you could do, you could right-click directly in the editor, open the current file on GitHub, and it would go to your SHA, not your branch name, as
I want to explain why opening to the SHA is more helpful than branch name (for clarity, it's the difference between an URL like this and one like this). Very often, I'll check out a new branch to start work on something. As I begin to explore the problem, I realize that I need to have a conversation with another developer on the team about the best way to approach a problem. My company works remote and uses Slack, so this means sharing GitHub links. Unless I push an empty branch to GitHub, then the resulting link is a 404. Pushing an empty branch is annoying, because nobody wants to have to push something to GitHub until they have a dirty working tree and an actual change to commit. Otherwise they risk having empty unused branches on GitHub that they then have to clean up in the future. It's not an enjoyable workflow. SHAs, on the other hand, are not 404s, because the SHA for a given file does not change from one branch to the next, so long as that file has not been changed.
Granted, this cuts both ways. If you push a branch to GitHub, make some more changes locally, commit them, but don't push the commit, and then right-click and "Open on GitHub" and that triggers a branch-based URL opening in your browser, you'll get a 200, but if it triggers a SHA-based URL, you'll get a 404. However, I think it's fair to say that this is a much less common scenario, and in that case, you can simply
There's a second reason that opening to the SHA is more valuable than a branch, and that is this. When you share a branch-based GitHub link, it's almost never because you're wanting to call attention to that branch as that branch but rather, you're calling attention to a file in its current state. For example, if I link to line 37 of a branch named
I'm opening this PR to begin some discussion. I doubt the code in its current form can be merged per se. I imagine we'll want to create a user setting so the user can switch between branch and SHA (though I'd love to default to SHA, because I truly believe from my reasons above that it's the superior method for most developers most of the time). Regardless, I've created a VSIX of this clone and it's the version of this extension that I'm using locally for now.