Skip to content

Commit c424b13

Browse files
committed
Fix: Hash detection affects all Search results
1 parent 7e3e577 commit c424b13

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

nupm/install.nu

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ def fetch-package [
207207
throw-error $'No package matching version `($version)`'
208208
}
209209

210+
if $pkg.dirty {
211+
throw-error ($'Content of package file `($pkg.path)'
212+
+ $'` does not match expected hash.')
213+
}
214+
210215
print $pkg
211216

212217
if $pkg.type == 'git' {

nupm/search.nu

+13-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ export def main [
1313
search-package $package --registry $registry --exact-match=$exact_match
1414
| flatten
1515
| each {|row|
16-
{
17-
registry_name: $row.registry_name
18-
registry_path: $row.registry_path
19-
name: $row.pkgs.name
20-
version: $row.pkgs.version
21-
path: $row.pkgs.path
22-
type: $row.pkgs.type
23-
info: $row.pkgs.info
16+
if $row.pkgs.dirty {
17+
null
18+
} else {
19+
{
20+
registry_name: $row.registry_name
21+
registry_path: $row.registry_path
22+
name: $row.pkgs.name
23+
version: $row.pkgs.version
24+
path: $row.pkgs.path
25+
type: $row.pkgs.type
26+
info: $row.pkgs.info
27+
}
2428
}
2529
}
26-
| filter-by-version $pkg_version
30+
| compact | filter-by-version $pkg_version
2731
}

nupm/utils/registry.nu

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use misc.nu [check-cols url hash-file]
88
export const REG_COLS = [ name path hash ]
99

1010
# Columns of a registry package file
11-
export const REG_PKG_COLS = [ name version path type info ]
11+
export const REG_PKG_COLS = [ name version path type info dirty ]
1212

1313
# Search for a package in a registry
1414
export def search-package [
@@ -86,19 +86,17 @@ export def search-package [
8686

8787
let new_hash = $pkg_file_path | hash-file
8888

89-
if $new_hash != $row.hash {
90-
throw-error ($'Content of package file ($pkg_file_path)'
91-
+ $' does not match expected hash ($row.hash)')
92-
}
89+
# check package hash
90+
let dirty = $new_hash != $row.hash
9391

94-
open $pkg_file_path
92+
open $pkg_file_path | insert dirty $dirty
9593
}
9694
| flatten
9795

9896
{
9997
registry_name: $name
10098
registry_path: $registry.path
101-
pkgs: $pkgs
99+
pkgs: $pkgs,
102100
}
103101
}
104102
| compact

0 commit comments

Comments
 (0)