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 an action to copy a link to a file in the online repository for a module dependency #3656

Open
YesYouKenSpace opened this issue Jan 9, 2025 · 9 comments

Comments

@YesYouKenSpace
Copy link

Is your feature request related to a problem? Please describe.
I would like to share reference to lines of code in public repository of imported packages when discussing issues with my teammates.

Describe the solution you'd like
It would be nice to have an action item in the context menu under Copy As > Copy link to remote repository
image

Describe alternatives you've considered

Additional context

@gopherbot gopherbot added this to the Untriaged milestone Jan 9, 2025
@h9jiang
Copy link
Member

h9jiang commented Jan 9, 2025

Hi YesYouKenSpace,

I find a tool offered from GitLens. I'm not sure if this is something you are looking for. If you configured correctly, you will find options below.

image

But this is limited to understanding your repo allow you to customize the repo url with file, line and range parameter. It does not understand the library you imported in your repo unless you vendor them (make those as part of your repo). But standard lib is always out of reach because it can not be vendored.

@h9jiang h9jiang added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 9, 2025
@firelizzard18
Copy link
Contributor

I think what they mean is: If I open a file from the module cache (for example by using "Go to definition" on an imported type), I want a "Copy link to file" menu option that links to the online repository for that package. I don't think GitLens can solve this because the module cache files aren't git repositories.

@YesYouKenSpace If I'm correct this would be tricky to handle in the general case. Obviously if the module starts with github.com it's not that hard to determine a browsable URL for that file. However supporting other providers would require a go-get query for each module and that only works if the provider includes a go-source meta tag.

@gopherbot
Copy link
Collaborator

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2025
@YesYouKenSpace
Copy link
Author

@firelizzard18 yeap you are right that is what i meant. I think even if supporting just the common code hosting sites is good enough for most open source projects. Already makes it easier to reference open source libraries.

@YesYouKenSpace
Copy link
Author

@h9jiang thank you for pointing out gitlens. I do have gitlens too and i was unable to refer to the lib that are imported.

@firelizzard18 firelizzard18 reopened this Feb 11, 2025
@firelizzard18 firelizzard18 added FeatureRequest and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Feb 11, 2025
@firelizzard18 firelizzard18 changed the title Allow Copy Link To File on imported packages Add an action to copy a link to a file in the online repository for a module dependency Feb 11, 2025
@firelizzard18
Copy link
Contributor

firelizzard18 commented Feb 11, 2025

@YesYouKenSpace Can you clarify when you want this option to appear? I can think of multiple scenarios. I had been thinking when you right click the file tab after opening a file from the module cache as in [right click method/etc] -> [go to definition] -> [right click file tab] -> [copy link] but from your screenshot it looks like you want this option to appear when right clicking a definition, as in [right click method/etc] -> [copy link] as an alternative to [go to definition].

@YesYouKenSpace
Copy link
Author

@firelizzard18 i expect it to be available at a right click on any line within a file of the module cache. I believe that to be the most intuitive.

I imagine myself navigating in the team codebase and then travelling to the public library definition and finding a piece of code in the module cache that explains a behaviour and wanting to link my teammates to that line.

@firelizzard18
Copy link
Contributor

That's sufficiently clear. The request is:

  • As a user, when I open a file within the module cache, I want a context menu option to copy a link to the online repository for that file.
  • For example, if I open ~/go/pkg/mod/github.com/spf13/[email protected]/command.go (e.g. by Go to Definition) and I right click, I want a context menu option that will place https://github.com/spf13/cobra/blob/v1.8.1/command.go on the clipboard, ideally with #LXX for the line number I right clicked on.

As far as implementation, it should be relatively straightforward for github, gitlab, and other well-known providers. Supporting arbitrary providers (e.g. custom GitLab deployments such as https://gitlab.freedesktop.org/) will require checking for a go-source meta tag with a go-get query as I mentioned before #3656 (comment).

@YesYouKenSpace
Copy link
Author

Thank you good sir @firelizzard18, ah yes i probably should have just started with a user story.

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

4 participants