Skip to content

Commit

Permalink
Merge pull request #65 from Mic92/cargo-sha256
Browse files Browse the repository at this point in the history
allow to upload cargo checksum when source is local
  • Loading branch information
Mic92 authored Aug 26, 2021
2 parents 474e358 + 2f498d5 commit b167cc6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions nix_update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile
from typing import NoReturn, Optional

from .version.version import VersionPreference
from .eval import Package
from .options import Options
from .update import update
Expand Down Expand Up @@ -56,6 +57,7 @@ def parse_args() -> Options:
run=args.run,
shell=args.shell,
version=args.version,
version_preference=VersionPreference.from_str(args.version),
attribute=args.attribute,
test=args.test,
version_regex=args.version_regex,
Expand Down
7 changes: 4 additions & 3 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .errors import UpdateError
from .options import Options
from .version.version import VersionPreference
from .utils import run


Expand All @@ -24,7 +25,7 @@ class Package:
urls: Optional[List[str]]
url: Optional[str]
rev: str
hash: str
hash: Optional[str]
mod_sha256: Optional[str]
vendor_sha256: Optional[str]
cargo_sha256: Optional[str]
Expand Down Expand Up @@ -65,7 +66,7 @@ def eval_expression(import_path: str, attr: str) -> str:
urls = pkg.src.urls or null;
url = pkg.src.url or null;
rev = pkg.src.url.rev or null;
hash = pkg.src.outputHash;
hash = pkg.src.outputHash or null;
mod_sha256 = pkg.modSha256 or null;
vendor_sha256 = pkg.vendorSha256 or null;
cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null;
Expand All @@ -88,7 +89,7 @@ def eval_attr(opts: Options) -> Package:
res = run(cmd)
out = json.loads(res.stdout)
package = Package(attribute=opts.attribute, **out)
if package.old_version == "":
if opts.version_preference != VersionPreference.SKIP and package.old_version == "":
raise UpdateError(
f"Nix's builtins.parseDrvName could not parse the version from {package.name}"
)
Expand Down
2 changes: 2 additions & 0 deletions nix_update/options.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from dataclasses import dataclass
from .version.version import VersionPreference


@dataclass
class Options:
attribute: str
version: str = "stable"
version_preference: VersionPreference = VersionPreference.STABLE
version_regex: str = "(.*)"
import_path: str = "./."
commit: bool = False
Expand Down
10 changes: 5 additions & 5 deletions nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ def update(opts: Options) -> Package:

update_hash = True

version_preference = VersionPreference.from_str(opts.version)

if version_preference != VersionPreference.SKIP:
if opts.version_preference != VersionPreference.SKIP:
update_hash = update_version(
package, opts.version, version_preference, opts.version_regex
package, opts.version, opts.version_preference, opts.version_regex
)

if update_hash:
if package.hash and update_hash:
update_src_hash(opts, package.filename, package.hash)

# if no package.hash was provided we just update the other hashes unconditionally
if update_hash or not package.hash:
if package.vendor_sha256:
update_go_vendor_hash(opts, package.filename, package.vendor_sha256)
# legacy go module checksums
Expand Down

0 comments on commit b167cc6

Please sign in to comment.