Fix crash when inspecting Nix package with no deps (related to issue #12).

This commit is contained in:
Bryan Gardiner 2023-03-17 21:36:13 -07:00
parent 7f17e6cdf3
commit 8302026545
No known key found for this signature in database
GPG key ID: 53EFBCA063E6183C
2 changed files with 9 additions and 2 deletions

View file

@ -2,6 +2,10 @@
## 0.2.2 (unreleased) ## 0.2.2 (unreleased)
- Fixed crash when `nix-store --query --references` returns nothing (e.g. for a
Nix package with no dependencies), which causes the assertion from issue #12
to fail.
## 0.2.1 (2023-03-17) ## 0.2.1 (2023-03-17)
- Fixed reference to undefined variable in `StorePath` constructor (issue #12), - Fixed reference to undefined variable in `StorePath` constructor (issue #12),

View file

@ -228,11 +228,14 @@ class PackageManifest:
@staticmethod @staticmethod
def parse_tree(root: Path) -> "PackageManifest": def parse_tree(root: Path) -> "PackageManifest":
direct_deps: List[str] = subprocess.run( direct_deps_str: str = subprocess.run(
[make_nix_bin_path("nix-store"), "--query", "--references", str(root)], [make_nix_bin_path("nix-store"), "--query", "--references", str(root)],
stdout=PIPE, stdout=PIPE,
text=True text=True
).stdout.rstrip("\n").split("\n") ).stdout.rstrip("\n")
direct_deps: List[str] = \
direct_deps_str.split("\n") if direct_deps_str else []
packages = [] packages = []
for dep_path in direct_deps: for dep_path in direct_deps: