loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Return `repository` in npm package metadata endpoint (#23539)

Close #23444

Add `Repository` to npm package `Metadata` struct so the `repository` in
`package.json` can be stored and be returned in the endpoint.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

authored by

Zettat123
KN4CK3R
and committed by
GitHub
46addc1f d0f48187

+18
+1
modules/packages/npm/creator.go
··· 223 223 OptionalDependencies: meta.OptionalDependencies, 224 224 Bin: meta.Bin, 225 225 Readme: meta.Readme, 226 + Repository: meta.Repository, 226 227 }, 227 228 } 228 229
+7
modules/packages/npm/creator_test.go
··· 26 26 packageDescription := "Test Description" 27 27 data := "H4sIAAAAAAAA/ytITM5OTE/VL4DQelnF+XkMVAYGBgZmJiYK2MRBwNDcSIHB2NTMwNDQzMwAqA7IMDUxA9LUdgg2UFpcklgEdAql5kD8ogCnhwio5lJQUMpLzE1VslJQcihOzi9I1S9JLS7RhSYIJR2QgrLUouLM/DyQGkM9Az1D3YIiqExKanFyUWZBCVQ2BKhVwQVJDKwosbQkI78IJO/tZ+LsbRykxFXLNdA+HwWjYBSMgpENACgAbtAACAAA" 28 28 integrity := "sha512-yA4FJsVhetynGfOC1jFf79BuS+jrHbm0fhh+aHzCQkOaOBXKf9oBnC4a6DnLLnEsHQDRLYd00cwj8sCXpC+wIg==" 29 + repository := Repository{ 30 + Type: "gitea", 31 + URL: "http://localhost:3000/gitea/test.git", 32 + } 29 33 30 34 t.Run("InvalidUpload", func(t *testing.T) { 31 35 p, err := ParsePackage(bytes.NewReader([]byte{0})) ··· 242 246 Dist: PackageDistribution{ 243 247 Integrity: integrity, 244 248 }, 249 + Repository: repository, 245 250 }, 246 251 }, 247 252 }, ··· 272 277 assert.Equal(t, "https://gitea.io/", p.Metadata.ProjectURL) 273 278 assert.Contains(t, p.Metadata.Dependencies, "package") 274 279 assert.Equal(t, "1.2.0", p.Metadata.Dependencies["package"]) 280 + assert.Equal(t, repository.Type, p.Metadata.Repository.Type) 281 + assert.Equal(t, repository.URL, p.Metadata.Repository.URL) 275 282 }) 276 283 }
+1
modules/packages/npm/metadata.go
··· 21 21 OptionalDependencies map[string]string `json:"optional_dependencies,omitempty"` 22 22 Bin map[string]string `json:"bin,omitempty"` 23 23 Readme string `json:"readme,omitempty"` 24 + Repository Repository `json:"repository,omitempty"` 24 25 }
+1
routers/api/packages/npm/api.go
··· 45 45 Author: npm_module.User{Name: metadata.Author}, 46 46 License: metadata.License, 47 47 Versions: versions, 48 + Repository: metadata.Repository, 48 49 } 49 50 } 50 51
+8
tests/integration/api_packages_npm_test.go
··· 37 37 packageDescription := "Test Description" 38 38 packageBinName := "cli" 39 39 packageBinPath := "./cli.sh" 40 + repoType := "gitea" 41 + repoURL := "http://localhost:3000/gitea/test.git" 40 42 41 43 data := "H4sIAAAAAAAA/ytITM5OTE/VL4DQelnF+XkMVAYGBgZmJiYK2MRBwNDcSIHB2NTMwNDQzMwAqA7IMDUxA9LUdgg2UFpcklgEdAql5kD8ogCnhwio5lJQUMpLzE1VslJQcihOzi9I1S9JLS7RhSYIJR2QgrLUouLM/DyQGkM9Az1D3YIiqExKanFyUWZBCVQ2BKhVwQVJDKwosbQkI78IJO/tZ+LsbRykxFXLNdA+HwWjYBSMgpENACgAbtAACAAA" 42 44 ··· 62 64 "dist": { 63 65 "integrity": "sha512-yA4FJsVhetynGfOC1jFf79BuS+jrHbm0fhh+aHzCQkOaOBXKf9oBnC4a6DnLLnEsHQDRLYd00cwj8sCXpC+wIg==", 64 66 "shasum": "aaa7eaf852a948b0aa05afeda35b1badca155d90" 67 + }, 68 + "repository": { 69 + "type": "` + repoType + `", 70 + "url": "` + repoURL + `" 65 71 } 66 72 } 67 73 }, ··· 169 175 assert.Equal(t, "sha512-yA4FJsVhetynGfOC1jFf79BuS+jrHbm0fhh+aHzCQkOaOBXKf9oBnC4a6DnLLnEsHQDRLYd00cwj8sCXpC+wIg==", pmv.Dist.Integrity) 170 176 assert.Equal(t, "aaa7eaf852a948b0aa05afeda35b1badca155d90", pmv.Dist.Shasum) 171 177 assert.Equal(t, fmt.Sprintf("%s%s/-/%s/%s", setting.AppURL, root[1:], packageVersion, filename), pmv.Dist.Tarball) 178 + assert.Equal(t, repoType, result.Repository.Type) 179 + assert.Equal(t, repoURL, result.Repository.URL) 172 180 }) 173 181 174 182 t.Run("AddTag", func(t *testing.T) {