Skip to content

Nuspec "repository" field to automatically set repository link, branch and commit of uploaded packages #38127

@flod1

Description

@flod1

What problem would this solve?

Feature Description

When a NuGet package is published, Gitea parses the .nuspec manifest but only
extracts the url attribute from the <repository> element (stored as
RepositoryURL). The additional, officially supported attributes type,
branch and commit are discarded during parsing and are therefore never shown
on the package detail page.

Example <repository> element as defined by the NuGet spec (supported since 2016):

<repository type="git"
            url="https://gitea.example.com/owner/repo.git"
            branch="main"
            commit="0123456789abcdef0123456789abcdef01234567" />

These attributes carry useful provenance information: they let a package consumer
see exactly which branch and commit a given package version was built from, which
is valuable for traceability and reproducibility.

Proposal

  1. Extend the nuspec parser (modules/packages/nuget/metadata.go) to read the
    type, branch and commit attributes of the <repository> element.
  2. Add corresponding fields to the Metadata struct (e.g. RepositoryType,
    RepositoryBranch, RepositoryCommit).
  3. Render these fields on the package detail page template
    (templates/package/content/nuget.tmpl), e.g. as a small "Source" section,
    ideally with the commit linked to the repo when the URL points to the same
    Gitea instance.

Notes

Screenshots

N/A

What do you propose?

please extend the template und parse the 3 attributes. thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/proposalThe new feature has not been accepted yet but needs to be discussed first.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions