reduckted / gitweblinks Goto Github PK
View Code? Open in Web Editor NEWCopy links to files in their online Git repositories from inside Visual Studio Code and Visual Studio 2022.
License: MIT License
Copy links to files in their online Git repositories from inside Visual Studio Code and Visual Studio 2022.
License: MIT License
I'm not sure how long this has been available in VS Code, but I noticed a menu that now that allows you to retrieve the same link made possible by this extension (along with some other nice ones like to master
, vscode.dev
& markdown
):
I think that makes this extension obsolete for users of Github repositories & VS Code using at least 1.73.1
?
From Parameter to disable markdown rendering, GitHub introduced a new URL parameter on June 30, 2021:
Appending
?plain=1
to the url for any Markdown file will now display the file without rendering. As with other code files, it will also show line numbers, and can be used to link other users to a specific line or lines. For example, appending?plain=1#L52
will highlight line 52 of a plain text Markdown file.
It would be great if links to selection in markdown files could use plain=1
, since otherwise they will have no effect.
Hello, great extension, thank you!
Very useful for code peer reviews over Slack / instant messaging, to exchange URLs whilst working locally from VSCode.
However the inverse functionality would be very useful too.
For example I would like to be able to copy such URL: https://github.com/reduckted/vscode-gitweblinks/blob/1244479c00a2192e6100f49296fd97f92bb8e4e5/src/utilities/ServerUrl.ts#L2-L4
...and to show src/utilities/ServerUrl.ts
in VSCode with the code selection line 2-4 (extracted from the URL #L2-L4
).
Any thoughts?
After last update to v2.1.0.
Message for all files: The file 'file:///home/…file.json' is not tracked by Git. Everything worked well before.
URL settings have been updated from baseUrl/sshUrl to http/ssh:
"gitweblinks.gitLabEnterprise": [
{
"http": "https://git.example.ru/reps/rep1",
"ssh": "[email protected]/rep1.git"
}
],
Unless I'm missing something, this plugin doesn't work when the VSCode workspace encompasses multiple repositories. In my case, I have one workspace (~/code), that has many subdirectories each of which contains their own git repository.
[11:52:38.032] Could not find the root directory of the Git repository.
[11:52:38.032] Could not find Git info for path '/Users/npastor/code'.
I assume the extension is just looking in that workspace root for a git repo. Would it be hard to traverse up (or down) the the directory tree to find a git repo?
I use the extension every day. But almost always, when I copy a link, I want to open my browser and paste this to open it.
I added 'Open in Web' button when copying
maybe add an 'open/copy' option to the settings?
GitHub Enterprise Server URI is not a valid URI: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "git.drillinginfo.com", query: "", fragment: ""}
"gitweblinks.gitHubEnterprise": [
{
"http": "https://git.drillinginfo.com",
}
],
Copy Web Link To File
has completely disappeared from my right-click menu in VS Code (first noticed 2/3 weeks ago).
Reading through https://marketplace.visualstudio.com/items?itemName=reduckted.vscode-gitweblinks I noticed you can also use the extension via the Command Palette, but when I try and execute any of the commands listed I get a workspace error
The workspace at 'file:///Users/my_user/dev/ruben' is not tracked by Git.
I might use workspaces in a different way to others, but I usually have a big folder open as the root of the workspace (e.g. work
) which contains a lot of individual repos (e.g. work/user-microservice
, work/some-other-microservice
).
This seemed to pose no issues up until a few weeks ago.
The error reads as if the extension is no longer looking through the directories to find the .git
folder closest to the file I'm trying to create a link for, instead it just looks into the root of the workspace folder and errors. I'm presuming this is the same reason the option has disappeared from the menu.
Git Web Links For VS Code:
2.0.0 (2020-12-30)
(looks like a version was released that co-incided with my issue, time-wise)
VS Code:
Version: 1.52.1
Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523
Date: 2020-12-16T16:30:02.420Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 18.7.0
Please, add support of custom url for Azure DevOps|
Url examples:
file:
https://{custom.site.net}/tfs/DefaultCollection/{project}/_git/{repository}?path=%2FConfig%2FWebApplications&version=GBdevelop
selection:
https://{custom.site.net}/tfs/DefaultCollection/{project}/_git/{repository}?path=%2FConfig%2FWebApplications%2Freadme.txt&version=GBdevelop&line=1&lineEnd=1&lineStartColumn=14&lineEndColumn=23&lineStyle=plain
If a user is …
… then you can:
Copy Web Link to Selection
In the .gif
below you'll see I am a user who …
then I …
Copy Web Link to Selection
404
errorto confirm this isn't an access issue, afterward I:
Copy permalink
404
error)Steps to reproduce the behavior:
A
with code file B
B
Copy Web Link to Selection
404
errorCode
tab in GitHub for repo A
B
to confirm it exists and you can access itIt would be awesome to (optionally?) shorten the links pointing at specific commits by using the --short
option on git rev-parse.
See https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
Here's a link with a full SHA as currently generated:
GitWebLinks/vscode/src/link-handler.ts
Line 273 in 3cb46cb
The same link again but with a short SHA:
https://github.com/reduckted/GitWebLinks/blob/3cb46c/vscode/src/link-handler.ts#L273
So It looks like GH's preview feature only works with full SHAs, but it's still nice to have the short one to send to humans or to link in code.
When I select the gitweblinks.copySelection
or gitweblinks.copyFile
actions in the command palette (shift+cmd+p
) nothing happens. I bound gitweblinks.copySelection
to a keyboard shortcut and that doesn't work either. I'm on MacOS Catalina.
In the meantime this extension works great via right click, thanks for sharing it.
VSCode version:
Version: 1.42.0
Commit: ae08d5460b5a45169385ff3fd44208f431992451
Date: 2020-02-06T10:51:33.119Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 19.3.0
Culprit commit:
e42e29a
I discovered this bug by opening "Toggle Keyboard Shortcuts Troubleshooting" in Visual Studio Code's command palette (SHIFT + CMD + P).
My workaround is to disable your extension (unfortunately), so I can continue to use my essential "find next" keyboard shortcut.
If I select two lines in VSCode (say 462 and 463) and "Copy Link to Selection", I end up with the following anchor in the GitHub URL #L462-L464
. Instead, this should be #L462-L463
This is a feature request to include a 4th link format branch only. This format only contains the branch name and not the commit SHA, eg https://bitbucket.org/myworkspace/myrepo/src/main/README.md.
This would be useful for providing permanent links to files with changing content but unchanging location.
Like https://github.com/kawamataryo/copy-git-link for JetBrains, it would be nice if there would be an option to generate markdown that looks like this (code snippet included if text is selected):
[/somepackage/SomeClass.java#L42-L44](https://github.com/huyz/myrepo/blob/67b33efca188/somepackage/SomeClass.java#L42-L44)
```java
public void setLast_name(String last_name) {
this.last_name = last_name;
}
```
I downloaded the plugin yesterday and I'm excited about it, because I like to send code links. This simplifies my process a lot. Thanks for developing!
I see that origin
is picked as the default remote [1]. And this seems like a good decision given how git is typically used. But in repositories with more than one remote, it would be nice to have a way of picking a repository.
A minimal (but maybe not very) way of supporting this would be to pick with the highest priority a remote name like GitWebLinks
. Then, the user can just add that additional remote to the repository and decide for every repository which remote should be used by default. Of course, other more configurable options would be nice. But maybe this suggestion is suited best for a quick upgrade.
[1]
GitWebLinks/vscode/src/repository-finder.ts
Line 244 in b200985
I forked and added a feature for adding GitLab and GLE. I can create a PR, but it would probably be just as easy for you to add. All that I did was copy the GitHubHandler and change the multiline selection code from #L1-L5 to #L1-5.
Let me know if you'd prefer that I submitted a PR.
I am currently looking for a solution for links to files/commits in gitea repos.
Would it be possible to extend this extension for this? (Example repos)
or generally to custom links where you can build your own link with placeholders?
Looks like a change in the default branch is causing many tests to fail.. as an example:
93) Link handlers
Visual Studio Team Services
createUrl
ssh with protocol:
Link does not match the expected result
+ expected - actual
-https://foo.visualstudio.com/_git/bar?path=%2Fsrc%2Ffile.txt&version=GBmain
+https://foo.visualstudio.com/_git/bar?path=%2Fsrc%2Ffile.txt&version=GBmaster
at /Users/reecedaniels/dev/general/_OPEN-SOURCE-REPOS/GitWebLinks/vscode/out-test/test/handlers.test.js:174:96
at Generator.next (<anonymous>)
at fulfilled (out-test/test/handlers.test.js:5:58)
I have 104 failures locally
is is possible to add supporting for vscode workspace setting support, by this feature, we are able to sync repository config between team members, to avoid telling everyone how to config the plugin.
First of all, thank you very much for creating this super-useful extension!
I think the situations are not uncommon when a person can have more than one GitHub account - there can be several accounts for work and at least one personal.
To allow SSH find the right key for the account used for the repo, the remote URL must contain the username. In other words, in the local git config the URL is written like so:
[remote "origin"]
url = [email protected]:account_name/repo.git
But when Git Web Links creates a link, I believe it mistakenly includes the username:
https://github.com/-username:account_name/repo/blob/123abc/path/to/file.rb#L123
A correct link will not contain the username:
https://github.com/account_name/repo/blob/123abc/path/to/file.rb#L123
Do you think it's possible to fix this?
When I generate link to my private GitLab repo with "Copy Web Link to File", there is extra "-" character between repo name and "blob", which makes URL 404. Of course, I can manually delete "-".
Example:
https://gitlab2.ams.creativecdn.net/ai-lab/incrementality-suite/-/blob/master/package.json
should be:
https://gitlab2.ams.creativecdn.net/ai-lab/incrementality-suite/blob/master/package.json
--
I use below settings.json:
"gitweblinks.gitLabEnterprise": [
{
"baseUrl": "https://gitlab2.ams.creativecdn.net",
"sshUrl": "[email protected]"
}
]
It successfully copies a link to /.../project/file.md
but fails to work with /.../project/subdir/file.md
with error The repository /.../project/subdir does not have any remotes
What could be the reason?
I'm getting a This workspace is not tracked by Git.
(it is). What can I do to fix/debug this? VS Code's native Git integration and Git Lens work without any issue.
Here is some portions of the (git repo root)/.editor/.code-workspace
file that might be relevant:
{
"folders": [
{
"path": ".."
}
],
(...)
"search.exclude": {
"**/.git/**": true,
(...)
},
"search.followSymlinks": false,
"files.watcherExclude": {
"**/.git/**": true,
(...)
}
},
(...)
}
the copied link replace '/' with %2f and the browser fails to open it:
You should not encode these:
encodeURI(branchOrHash),
encodeURI(relativePathToFile)
If I open the root folder of a Git worktree in VS Code, open a file, and try to use any of the commands to copy a link, I get an error The workspace at 'file:///Users/me/git/my-repo-worktree' is not tracked by Git.
The commands work fine in the main local copy of the same repo.
Worktrees are implemented with a .git
file which points to the the actual directory:
/my-repo-worktree
.git file with contents:
gitdir: /(actual path here)/my-repo/.git/worktrees/my-repo-worktree
/my-repo
.git/
worktrees/
my-repo-worktree/
(normal .git folder stuff)
So this line ought to allow .git
to be either a file or directory.
https://github.com/reduckted/vscode-gitweblinks/blob/d7bc2db7102f07032f5af2262bfd83942fdb86c4/src/repository-finder.ts#L64
Then if all you're doing is running git commands, that can be done from the root of the worktree. (Only need to bother with looking in my-repo/.git/worktrees/my-repo-worktree/
if you need to dig into the .git folder contents, which I'd guess isn't needed?)
There is a file with a name like the sample.json#etc
.
The generated url for the file should be https://github.com/user/repo/blob/commit/sample.json%23etc
.
This #
is part of the filename, not a URL fragment, so it should be encoded.
The generated url for the file is https://github.com/user/repo/blob/commit/sample.json#etc
.
Therefore, it will not work as a correct link.
Other characters that can be used in file names and are special in URLs (such as ?
etc.) are not encoded as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.