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

feat: link to nuget dependencies #26554

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

lonix1
Copy link
Contributor

@lonix1 lonix1 commented Aug 17, 2023

Add links to dependencies and their versions, as done in nuget site. Makes it easier to use.

cc @KN4CK3R

@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 17, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 17, 2023
@KN4CK3R
Copy link
Member

KN4CK3R commented Aug 17, 2023

Not every dependecy is hosted on nuget.org

@lonix1
Copy link
Contributor Author

lonix1 commented Aug 17, 2023

Good point!

Do you think there's a way to detect that?

@silverwind
Copy link
Member

silverwind commented Aug 19, 2023

Looking at a nuspec file, dependencies do not list their URL there, so I'm afraid it's not possible to know where a package is hosted. Question is thought if we could accept potentially being wrong with these URLs.

<dependency id="Microsoft.CSharp" version="4.3.0" exclude="Build,Analyzers" />

@silverwind
Copy link
Member

On the other hand, how do private dependencies look in the nuspec file? I assume there must be some kind of URL so the package is able to be retrieved. If that is so, you can distinguish private packages.

@lonix1
Copy link
Contributor Author

lonix1 commented Aug 19, 2023

I suspect you are right there is no way to extract the URL (but I don't know for sure!). So I can delete this PR if you agree.

However, if that is the case, how does nuget do it? Each package on nuget links to other packages. So they just assume everything is on nuget? I guess when you are as big as Microsoft you can make those assumptions and get away with it! :-)

@silverwind
Copy link
Member

So they just assume everything is on nuget

I think that must be the case, yes. So until the package metadata gains a field to specify registry, there can only be guessing.

I still think a bad guess is better than no link, so I can accept this nonetheless.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 20, 2023
@lafriks
Copy link
Member

lafriks commented Aug 20, 2023

Maybe we can check first if it is local dependency in this instance and link to it and only use nuget.org as fallback?

@silverwind
Copy link
Member

silverwind commented Aug 20, 2023

Maybe we can check first if it is local dependency in this instance and link to it and only use nuget.org as fallback?

Great idea. That would be ideal, yes.

@lonix1
Copy link
Contributor Author

lonix1 commented Aug 21, 2023

Maybe we can check first if it is local dependency in this instance and link to it and only use nuget.org as fallback?

So that I understand, let's say you have package MyOrg.Server with dependencies:

  • Microsoft.Foo
  • Microsoft.Bar
  • ThirdParty.Foo
  • MyOrg.Utils
  • MyOrg.Common

Then MyOrg.* would be found in the gitea instance and so links would be created as I noted above. But the rest would not be found, so one would create links to nuget instead?

(If that's the case, I'm not a go dev, so I don't know how to improve this PR... sorry!)

@silverwind
Copy link
Member

silverwind commented Aug 21, 2023

Yes, correct. I estimate that the majority of use cases of private packages are with a single local registry with fallback to an official one. Multiple private registries could only be supported with additional metadata in the package's dependencies.

@silverwind
Copy link
Member

silverwind commented Aug 21, 2023

@KN4CK3R I think such a linkification would be nice for all package registries. Check if dependency exists in local registry, link there if it exists, otherwise link to official registry.

@wxiaoguang
Copy link
Contributor

I agree with some options above: such link for all packages is not ideal. Especially it might confuse and scare users who are using private packages and care about privacy a lot.

Maybe a better (but still not ideal) solution is to add a separate link "Search it in NuGet Gallery"

@silverwind
Copy link
Member

silverwind commented Sep 4, 2023

A link won't hurt anyone, I suppose.

We could decorate it with link-external to reinforce that it's external.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants