mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
fix: disable sha256 for local packages
This commit is contained in:
parent
4de4096004
commit
db1aae9b08
2 changed files with 17 additions and 3 deletions
|
|
@ -50,7 +50,7 @@ func TestInstallCommand(t *testing.T) {
|
||||||
URIs: []string{"jsonnet/foobar"},
|
URIs: []string{"jsonnet/foobar"},
|
||||||
ExpectedCode: 0,
|
ExpectedCode: 0,
|
||||||
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "jsonnet/foobar"}}, "version": ""}]}`),
|
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "jsonnet/foobar"}}, "version": ""}]}`),
|
||||||
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "jsonnet/foobar"}}, "version": "", "sum": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="}]}`),
|
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "jsonnet/foobar"}}, "version": ""}]}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,10 @@ func download(d spec.Dependency, vendorDir string) (*spec.Dependency, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sum := hashDir(filepath.Join(vendorDir, d.Name))
|
var sum string
|
||||||
|
if d.Source.LocalSource == nil {
|
||||||
|
sum = hashDir(filepath.Join(vendorDir, d.Name))
|
||||||
|
}
|
||||||
|
|
||||||
return &spec.Dependency{
|
return &spec.Dependency{
|
||||||
Name: d.Name,
|
Name: d.Name,
|
||||||
|
|
@ -166,8 +169,19 @@ func download(d spec.Dependency, vendorDir string) (*spec.Dependency, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check returns whether the files present at the vendor/ folder match the
|
// check returns whether the files present at the vendor/ folder match the
|
||||||
// sha256 sum of the package
|
// sha256 sum of the package. local-directory dependencies are not checked as
|
||||||
|
// their purpose is to change during development where integrity checking would
|
||||||
|
// be a hindrance.
|
||||||
func check(d spec.Dependency, vendorDir string) bool {
|
func check(d spec.Dependency, vendorDir string) bool {
|
||||||
|
// assume a local dependency is intact as long as it exists
|
||||||
|
if d.Source.LocalSource != nil {
|
||||||
|
x, err := jsonnetfile.Exists(filepath.Join(vendorDir, d.Name))
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
if d.Sum == "" {
|
if d.Sum == "" {
|
||||||
// no sum available, need to download
|
// no sum available, need to download
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue