From 9da6413da08c607f7b38fdd4672e6e63b8b6bd50 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 7 Jul 2026 23:27:54 +0200 Subject: [PATCH 1/3] Add a test demonstrating `git` install errors --- tests/mod.nu | 22 ++++++++++++++++++++-- tests/packages/registry/registry.nuon | 1 + tests/packages/registry/spam_git.nuon | 1 + tests/packages/spam_git/nupm.nuon | 6 ++++++ tests/packages/spam_git/script.nu | 1 + tests/packages/spam_git/spam_git/mod.nu | 3 +++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/packages/registry/spam_git.nuon create mode 100644 tests/packages/spam_git/nupm.nuon create mode 100644 tests/packages/spam_git/script.nu create mode 100644 tests/packages/spam_git/spam_git/mod.nu diff --git a/tests/mod.nu b/tests/mod.nu index 5c710fc..5179771 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -1,9 +1,10 @@ -use std assert +use std/assert use ../nupm/utils/dirs.nu use ../nupm/utils/dirs.nu [ tmp-dir REGISTRY_FILENAME ] use ../nupm +const DIRNAME = path self . const TEST_REGISTRY_PATH = ([tests packages registry $REGISTRY_FILENAME] | path join) @@ -90,6 +91,17 @@ export def install-from-local-registry [] { nupm install spam_script check-file-content 0.2.0 } + + with-test-env { + $env.NUPM_GIT_CLONE_ARGS = [ + "--reference" + ($DIRNAME | path join ".." | path expand) + "--revision" + (git rev-parse HEAD) + ] + + nupm install spam_git + } } export def install-with-version [] { @@ -129,7 +141,7 @@ export def install-package-not-found [] { export def search-registry [] { with-test-env { - assert ((nupm search spam | length) == 4) + assert ((nupm search spam | length) == 5) } } @@ -177,6 +189,12 @@ export def generate-local-registry [] { nupm publish $tmp_reg_file --local --save --path (".." | path join $pkg) } + do { + let pkg = "spam_git" + cd ([tests packages $pkg] | path join) + nupm publish $tmp_reg_file --git --save --info {url: "https://github.com/nushell/nupm.git" revision: "main"} --path $"tests/packages/($pkg)" + } + let actual = open $tmp_reg_file | to nuon let expected = open $reg_file | to nuon diff --git a/tests/packages/registry/registry.nuon b/tests/packages/registry/registry.nuon index 27f90bd..a35d86e 100644 --- a/tests/packages/registry/registry.nuon +++ b/tests/packages/registry/registry.nuon @@ -2,6 +2,7 @@ [name, path, hash]; [spam_custom, spam_custom.nuon, "md5-7b3a5119d1af5a025dae32bcfc7cab96"], + [spam_git, spam_git.nuon, "md5-6d79981218772b4b130cb5d48b15a70f"], [spam_module, spam_module.nuon, "md5-618c7c8ed97b423f111790d97bcd8486"], [spam_script, spam_script.nuon, "md5-ce1b060a68ebb42291e364b5daa6d47a"], ] diff --git a/tests/packages/registry/spam_git.nuon b/tests/packages/registry/spam_git.nuon new file mode 100644 index 0000000..21561cd --- /dev/null +++ b/tests/packages/registry/spam_git.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [spam_git, "0.1.0", tests/packages/spam_git, git, {url: "https://github.com/nushell/nupm.git", revision: main}]] \ No newline at end of file diff --git a/tests/packages/spam_git/nupm.nuon b/tests/packages/spam_git/nupm.nuon new file mode 100644 index 0000000..14c91e4 --- /dev/null +++ b/tests/packages/spam_git/nupm.nuon @@ -0,0 +1,6 @@ +{ + name: spam_git, + type: module, + version: "0.1.0" + scripts: [script.nu] +} diff --git a/tests/packages/spam_git/script.nu b/tests/packages/spam_git/script.nu new file mode 100644 index 0000000..3d0e6d8 --- /dev/null +++ b/tests/packages/spam_git/script.nu @@ -0,0 +1 @@ +print 'git' diff --git a/tests/packages/spam_git/spam_git/mod.nu b/tests/packages/spam_git/spam_git/mod.nu new file mode 100644 index 0000000..d39e890 --- /dev/null +++ b/tests/packages/spam_git/spam_git/mod.nu @@ -0,0 +1,3 @@ +export def main [] { + "Hello Git!" +} From cb1e0089210a4f2b54b24fca70424dce7918c7fd Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 7 Jul 2026 23:30:29 +0200 Subject: [PATCH 2/3] Fix non-functioning `git` registry installation Merging this commit will fix #108 and fix #133 --- nupm/install.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nupm/install.nu b/nupm/install.nu index 73d6a82..6c4bd4c 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -174,7 +174,7 @@ def download-pkg [ throw-error $'Error cloning repository ($pkg.info.url)' } ( - assert (not ($pkg_dir | path exists)) + assert ($pkg_dir | path exists) $'Package path ($pkg.path) does not exist in cloned repository' --error-label={text: "path_missing", span:(metadata $pkg_dir | get span)} ) From cd314ce10faba3c8c5ed1497fc9e1ee147697ec8 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 8 Jul 2026 00:22:31 +0200 Subject: [PATCH 3/3] Allow running tests from within shallow clones --- tests/mod.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mod.nu b/tests/mod.nu index 5179771..10b77ba 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -94,7 +94,7 @@ export def install-from-local-registry [] { with-test-env { $env.NUPM_GIT_CLONE_ARGS = [ - "--reference" + "--reference-if-able" ($DIRNAME | path join ".." | path expand) "--revision" (git rev-parse HEAD)