Skip to content

Commit

Permalink
Merge pull request #324 from gepbird/skip-deps
Browse files Browse the repository at this point in the history
feat: add --src-only flag
  • Loading branch information
Mic92 authored Mar 10, 2025
2 parents 6891656 + c4bd791 commit cb6442f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
6 changes: 6 additions & 0 deletions nix_update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def parse_args(args: list[str]) -> Options:
help="Attribute of a subpackage that nix-update should try to update hashes for",
default=None,
)
parser.add_argument(
"--src-only",
help="Only update the source, not dependencies such as npmDeps, cargoDeps or nugetDeps",
action="store_true",
)
parser.add_argument(
"--option",
help="Nix option to set",
Expand Down Expand Up @@ -154,6 +159,7 @@ def parse_args(args: list[str]) -> Options:
system=a.system,
generate_lockfile=a.generate_lockfile,
lockfile_metadata_path=a.lockfile_metadata_path,
src_only=a.src_only,
extra_flags=extra_flags,
)

Expand Down
1 change: 1 addition & 0 deletions nix_update/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Options:
system: str | None = None
generate_lockfile: bool = False
lockfile_metadata_path: str = "."
src_only: bool = False
extra_flags: list[str] = field(default_factory=list)

def __post_init__(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ def update(opts: Options) -> Package:
subpackage_opts.version_preference = VersionPreference.SKIP
update(subpackage_opts)

# if no package.hash was provided we just update the other hashes unconditionally
if update_hash or not package.hash:
# if no package.hash was provided we just update the other hashes unless it should be skipped
if (update_hash or not package.hash) and not opts.src_only:
if package.go_modules:
update_go_modules_hash(opts, package.filename, package.go_modules)

Expand Down
48 changes: 48 additions & 0 deletions tests/test_src_only.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
import subprocess

import conftest

from nix_update import main


def test_update(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(
[
"--file",
str(path),
"--commit",
"nuget-deps-generate",
"--version",
"v1.1.1",
"--src-only",
]
)

nuget_deps_raw = subprocess.run(
[
"nix",
"eval",
"--json",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"nuget-deps-generate.nugetDeps",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
nuget_deps = json.loads(nuget_deps_raw)
assert len(nuget_deps) == 0

diff = subprocess.run(
["git", "-C", path, "log"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(diff)
assert "https://github.com/ExOK/Celeste64/compare/v1.1.0...v1.1.1" in diff

0 comments on commit cb6442f

Please sign in to comment.