Skip to content

Commit

Permalink
Ensure we resolve even uninstallable packages in lockfile; undo packa…
Browse files Browse the repository at this point in the history
…ge.IsLegacy change
  • Loading branch information
savil committed Aug 11, 2023
1 parent 3086074 commit 0dbee1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
17 changes: 10 additions & 7 deletions internal/devpkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,7 @@ func (p *Package) Versioned() string {
}

func (p *Package) IsLegacy() bool {
if !p.IsDevboxPackage() || p.isVersioned() {
return false
}
if p.IsInstallable() {
return false
}
return p.lockfile.Get(p.Raw).GetSource() == ""
return p.IsDevboxPackage() && !p.isVersioned() && p.lockfile.Get(p.Raw).GetSource() == ""
}

func (p *Package) LegacyToVersioned() string {
Expand Down Expand Up @@ -550,3 +544,12 @@ func (p *Package) StoreName() (string, error) {
}
return name, nil
}

func (p *Package) EnsureUninstallableIsInLockfile() error {
// TODO savil: Do we need the IsDevboxPackage check here?
if !p.IsInstallable() || !p.IsDevboxPackage() {
return nil
}
_, err := p.lockfile.Resolve(p.Raw)
return err
}
11 changes: 11 additions & 0 deletions internal/impl/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ func (d *Devbox) ensurePackagesAreInstalled(ctx context.Context, mode installMod
return err
}

// Update lockfile with new packages that are not to be installed
cfgPkgs, err := d.ConfigPackages()

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / golangci-lint (ubuntu-latest)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)) (typecheck)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / golangci-lint (ubuntu-latest)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages) (typecheck)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / auto-nix-install (ubuntu-latest)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / test (false, ubuntu-latest, true)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / test (false, ubuntu-latest, false)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / test-nix-versions (ubuntu-latest, 2.15.1)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / test-nix-versions (ubuntu-latest, 2.16.1)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)

Check failure on line 239 in internal/impl/packages.go

View workflow job for this annotation

GitHub Actions / test-nix-versions (ubuntu-latest, 2.17.0)

d.ConfigPackages undefined (type *Devbox has no field or method ConfigPackages, but does have configPackages)
if err != nil {
return err
}
for _, pkg := range cfgPkgs {
if err := pkg.EnsureUninstallableIsInLockfile(); err != nil {
return err
}
}

return d.lockfile.Save()
}

Expand Down

0 comments on commit 0dbee1d

Please sign in to comment.