Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: new generic package version/file enumeration api endpoint #35770

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

Open
imgurbot12 wants to merge 2 commits into go-gitea:main
base: main
Choose a base branch
Loading
from imgurbot12:feat/enum-generic
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: i forgor to run lint again after changing the struct names. unch...
...anged the names
  • Loading branch information
imgurbot12 committed Oct 29, 2025
commit b4efc0e726e2ab52e7f518ccba5036bf69740fce
18 changes: 9 additions & 9 deletions routers/api/packages/generic/generic.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ var (
filenameRegex = regexp.MustCompile(`\A[-_+=:;.()\[\]{}~!@#$%^& \w]+\z`)
)

// GenericPackageFileInfo represents information about an existing package file
// PackageFileInfo represents information about an existing package file
// swagger:model
type GenericPackageFileInfo struct {
type PackageFileInfo struct {
// Name of package file
Name string `json:"name"`
// swagger:strfmt date-time
// Date when package file was created/uploaded
CreatedUnix timeutil.TimeStamp `json:"created"`
}

// GenericPackageInfo represents information about an existing package file
// PackageInfo represents information about an existing package file
// swagger:model
type GenericPackageInfo struct {
type PackageInfo struct {
/// Version linked to package information
Version string `json:"version"`
/// Download count for files within version
DownloadCount int64 `json:"downloads"`
/// Files uploaded for package version
Files []GenericPackageFileInfo `json:"files"`
Files []PackageFileInfo `json:"files"`
}

func apiError(ctx *context.Context, status int, obj any) {
Expand All @@ -61,23 +61,23 @@ func EnumeratePackageVersions(ctx *context.Context) {
return
}

var info []GenericPackageInfo
var info []PackageInfo
for _, pv := range pvs {
packageFiles, err := packages_model.GetFilesByVersionID(ctx, pv.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}

var files []GenericPackageFileInfo
var files []PackageFileInfo
for _, file := range packageFiles {
files = append(files, GenericPackageFileInfo{
files = append(files, PackageFileInfo{
Name: file.Name,
CreatedUnix: file.CreatedUnix,
})
}

info = append(info, GenericPackageInfo{
info = append(info, PackageInfo{
Version: pv.Version,
DownloadCount: pv.DownloadCount,
Files: files,
Expand Down

AltStyle によって変換されたページ (->オリジナル) /