diff options
Diffstat (limited to 'internal/postgres')
| -rw-r--r-- | internal/postgres/insert_module.go | 12 | ||||
| -rw-r--r-- | internal/postgres/insert_module_test.go | 3 | ||||
| -rw-r--r-- | internal/postgres/path_test.go | 5 | ||||
| -rw-r--r-- | internal/postgres/unit.go | 8 | ||||
| -rw-r--r-- | internal/postgres/unit_test.go | 3 |
5 files changed, 5 insertions, 26 deletions
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go index bcfabf06..2db1695f 100644 --- a/internal/postgres/insert_module.go +++ b/internal/postgres/insert_module.go @@ -385,10 +385,8 @@ func insertUnits(ctx context.Context, db *database.DB, m *internal.Module, modul sort.Slice(m.Units, func(i, j int) bool { return m.Units[i].Path < m.Units[j].Path }) - for _, d := range m.Units { - if d.Package != nil && len(d.Imports) > 1 { - sort.Strings(d.Imports) - } + for _, u := range m.Units { + sort.Strings(u.Imports) } var ( pathValues []interface{} @@ -415,15 +413,11 @@ func insertUnits(ctx context.Context, db *database.DB, m *internal.Module, modul } } } - var name string - if d.Package != nil { - name = d.Package.Name - } pathValues = append(pathValues, d.Path, moduleID, internal.V1Path(d.Path, m.ModulePath), - name, + d.Name, pq.Array(licenseTypes), pq.Array(licensePaths), d.IsRedistributable, diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go index d5b717d6..49f0552a 100644 --- a/internal/postgres/insert_module_test.go +++ b/internal/postgres/insert_module_test.go @@ -121,9 +121,6 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) { Contents: sample.ReadmeContents, } wantu.LicenseContents = sample.Licenses - if wantu.Package != nil { - wantu.Name = wantu.Package.Name - } opts := cmp.Options{ cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeFilePath"), cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeContents"), diff --git a/internal/postgres/path_test.go b/internal/postgres/path_test.go index 86f026a5..44c2ff99 100644 --- a/internal/postgres/path_test.go +++ b/internal/postgres/path_test.go @@ -62,10 +62,7 @@ func TestGetUnitMeta(t *testing.T) { }, } if d == pkgPath { - dir.Package = &internal.Package{ - Path: pkgPath, - Name: pkgName, - } + dir.Name = pkgName dir.Documentation = &internal.Documentation{} } sample.AddUnit(m, dir) diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 2e16b7af..268c606b 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -122,14 +122,6 @@ func (db *DB) GetUnit(ctx context.Context, um *internal.UnitMeta, fields interna } u.LicenseContents = lics } - if fields == internal.AllFields { - if u.Name != "" { - u.Package = &internal.Package{ - Path: u.Path, - Name: u.Name, - } - } - } if !db.bypassLicenseCheck { u.RemoveNonRedistributableData() } diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go index 855be001..fa87fd93 100644 --- a/internal/postgres/unit_test.go +++ b/internal/postgres/unit_test.go @@ -335,7 +335,7 @@ func TestGetUnit(t *testing.T) { Filepath: sample.ReadmeFilePath, Contents: sample.ReadmeContents, } - if test.want.Package != nil { + if test.want.Name != "" { test.want.Imports = sample.Imports } test.want.SourceInfo = pathInfo.SourceInfo @@ -442,7 +442,6 @@ func unit(path, modulePath, version string, readme *internal.Readme, pkg *intern }, LicenseContents: sample.Licenses, Readme: readme, - Package: pkg, } if pkg != nil { u.Documentation = sample.Documentation |
