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)} ) diff --git a/tests/mod.nu b/tests/mod.nu index 5c710fc..10b77ba 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-if-able" + ($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!" +}