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
chore: move lockfile ffi boundary #4629
Changes from 1 commit
8c99b57
8d93b1e
ab9f0b3
f9a460c
4f9c395
31ef289
1c6d663
92f0b58
2efd867
57be317
0ff9dbc
1931953
fbdeffd
8c6c647
b0f20e7
d1c52da
fada352
9049e5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,10 @@ package fs | |
import ( | ||
"bytes" | ||
"encoding/json" | ||
"sort" | ||
"sync" | ||
|
||
mapset "github.com/deckarep/golang-set" | ||
"github.com/vercel/turbo/cli/internal/lockfile" | ||
"github.com/vercel/turbo/cli/internal/turbopath" | ||
) | ||
|
@@ -120,6 +122,24 @@ func MarshalPackageJSON(pkgJSON *PackageJSON) ([]byte, error) { | |
return b.Bytes(), nil | ||
} | ||
|
||
// SetExternalDeps sets TransitiveDeps and populates ExternalDepsHash | ||
func (p *PackageJSON) SetExternalDeps(externalDeps mapset.Set) error { | ||
p.Mu.Lock() | ||
defer p.Mu.Unlock() | ||
p.TransitiveDeps = make([]lockfile.Package, 0, externalDeps.Cardinality()) | ||
for _, dependency := range externalDeps.ToSlice() { | ||
dependency := dependency.(lockfile.Package) | ||
nathanhammond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
p.TransitiveDeps = append(p.TransitiveDeps, dependency) | ||
} | ||
sort.Sort(lockfile.ByKey(p.TransitiveDeps)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Teach me! Why was string sorting here not enough? (I read it but I don't have enough context to understand why we do it this way.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick history of the
|
||
hashOfExternalDeps, err := HashObject(p.TransitiveDeps) | ||
if err != nil { | ||
return err | ||
} | ||
p.ExternalDepsHash = hashOfExternalDeps | ||
return nil | ||
} | ||
|
||
func isEmpty(value interface{}) bool { | ||
if value == nil { | ||
return true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thing I investigated during review: why is this "every time" if you have a lockfile and not simply collapsing to
""
when empty?The answer:
ExternalDepsHash
being set to""
is basically aNone
sigil which is correctly distinct fromHash(Some({}))
.