Skip to content

Commit 3ea4c16

Browse files
committed
Update lockfile api for package source
1 parent f6f94fe commit 3ea4c16

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

internal/devpkg/package.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,12 @@ func (p *Package) Versioned() string {
403403
}
404404

405405
func (p *Package) IsLegacy() bool {
406-
return p.isDevboxPackage() && !p.isVersioned() && p.lockfile.Source(p.Raw) == ""
406+
var packageSource = ""
407+
if p.lockfile.Get(p.Raw) != nil {
408+
packageSource = p.lockfile.Get(p.Raw).Source
409+
}
410+
411+
return p.isDevboxPackage() && !p.isVersioned() && packageSource == ""
407412
}
408413

409414
func (p *Package) LegacyToVersioned() string {

internal/devpkg/package_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ func (l *lockfile) LegacyNixpkgsPath(pkg string) string {
119119
)
120120
}
121121

122-
func (l *lockfile) Source(pkg string) string {
123-
return ""
122+
func (l *lockfile) Get(pkg string) *lock.Package {
123+
return nil
124124
}
125125

126126
func (l *lockfile) Resolve(pkg string) (*lock.Package, error) {

internal/lock/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type devboxProject interface {
1111
}
1212

1313
type Locker interface {
14+
Get(string) *Package
1415
LegacyNixpkgsPath(string) string
1516
ProjectDir() string
1617
Resolve(string) (*Package, error)
17-
Source(string) string
1818
}

internal/lock/lockfile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ func (l *File) LegacyNixpkgsPath(pkg string) string {
130130
)
131131
}
132132

133-
func (l *File) Source(pkg string) string {
133+
func (l *File) Get(pkg string) *Package {
134134
entry, hasEntry := l.Packages[pkg]
135135
if !hasEntry || entry.Resolved == "" {
136-
return ""
136+
return nil
137137
}
138-
return entry.Source
138+
return entry
139139
}
140140

141141
// This probably belongs in input.go but can't add it there because it will

0 commit comments

Comments
 (0)