Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project.currentBranch and file.currentHash to URL context #185

Open
vergenzt opened this issue Dec 11, 2024 · 1 comment
Open

Add project.currentBranch and file.currentHash to URL context #185

vergenzt opened this issue Dec 11, 2024 · 1 comment

Comments

@vergenzt
Copy link

Use case: I'd like to be able to open the Github blame URL for the current version of the file I'm looking at. The URL for this needs the current hash of the file you're looking at (or the current branch containing that file).

Example

If I'm looking at the following line in VSCode:

for (const fileName of this.files.keys()) {

I'd love to be able to produce the following link:

https://github.com/Sertion/vscode-gitblame/blame/bb98406ab8837d506fb3b69e0a3147a06fbf0790/src/git/blame.ts#L115

Unfortunately, ${hash} when generating the URL for that line is correctly d220cd7 (i.e. the commit which touched that line), but the line number may only be accurate as of the current commit (i.e. bb98406).

My first attempt at getting the blame URL was to set gitblame.commitUrl to ${tool.protocol}//${gitorigin.hostname}${gitorigin.port}${gitorigin.path}/blame/${hash}/${file.path}#L${file.line}. This is incorrect as described below though, and results in the following URL:

https://github.com/Sertion/vscode-gitblame/blame/d220cd765dbe9f2661fd6e032c0dbfd05b0362d0/src/git/blame.ts#L115

which as of that version of the file the line number is now a completely different line 🙁

const gitRoot = getGitFolder(fileName);

@Sertion
Copy link
Owner

Sertion commented Dec 27, 2024

Hey Tim! Thank you for the feature request.

I've spent some time thinking about this request. I am still not sure what the future of the extension is now that Microsoft have added some (if not most) of the more visible features this extensions have to the official vscode git extension.

Perhaps the feature you are proposing would work best as an entirely new extension that could do similar things or perhaps it is best to propose this directly to the vscode team as a feature request for vscode.git?

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

No branches or pull requests

2 participants