diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fc71c9a..57437cb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: tests: uses: ./.github/workflows/nupm-tests.yml with: - nu_version: "0.88.1" - nupm_revision: "6a9618fa21453bca4000ac33707b7aace0da35c7" + nu_version: "0.89.0" + nupm_revision: "66e2eaa848e3f72c1b4a841f26f4dc7efc4fedb9" documentation: uses: ./.github/workflows/check-documentation.yml with: - nu_version: "0.88.1" + nu_version: "0.89.0" diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions/nu-complete.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions.nu similarity index 100% rename from pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions/nu-complete.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions.nu diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/git.nu similarity index 97% rename from pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/git.nu index a092f1da..af3bcced 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/git.nu @@ -1,4 +1,4 @@ -use ../../git/lib/style.nu [color] +use style.nu [color] # give the revision of the repo you're in # @@ -40,7 +40,7 @@ use ../../git/lib/style.nu [color] # │ type │ detached │ # ╰──────┴──────────╯ export def get-revision [ - --short-hash: bool # print the hash of a detached HEAD in short format + --short-hash # print the hash of a detached HEAD in short format ]: nothing -> record { let tag = do -i { ^git describe HEAD --tags @@ -119,3 +119,4 @@ export def get-status [ untracked: ($status | parse --regex '^\?\? (?.*)' | get file), } } + diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/mod.nu new file mode 100644 index 00000000..6a62b940 --- /dev/null +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/mod.nu @@ -0,0 +1,3 @@ +export module git.nu +export module prompt.nu +export module style.nu diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu index e9349ba1..181d4b02 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu @@ -1,5 +1,5 @@ -use ../../git/lib/lib.nu [get-revision, git-action, get-status] -use ../../git/lib/style.nu [color, simplify-path] +use git [get-revision, git-action, get-status] +use style.nu [color, simplify-path] # /!\ the PWD will be sanitized export def get-left-prompt [duration_threshold: duration]: nothing -> string { @@ -31,7 +31,7 @@ export def get-left-prompt [duration_threshold: duration]: nothing -> string { } let git_branch_segment = if $is_git_repo { - let revision = get-revision --short-hash true + let revision = get-revision --short-hash let pretty_branch_tokens = match $revision.type { "branch" => [ ($revision.name | color {fg: "yellow", attr: "ub"}), diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu index 9d6dfa15..3ba82e62 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu @@ -1,11 +1,14 @@ use std log -use ../git/lib/lib.nu [get-status] +module lib/ +use lib git [get-status] -use ../completions/nu-complete.nu [ +use completions [ GIT_QUERY_TABLES, GIT_STRATEGIES, git-query-tables, get-remotes, get-branches, get-strategies ] +export module prompt.nu + # get the commit hash of any revision # # ## Examples diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu index 2b7bb029..22248f59 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu @@ -1,4 +1,4 @@ -use ../git/lib/prompt.nu [get-left-prompt] +use lib prompt [get-left-prompt] const DEFAULT_PROMPT_INDICATORS = { plain: "> ", diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu index e69de29b..bdb38974 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu @@ -0,0 +1,4 @@ +module completions.nu +export module extra.nu +export module git/ +export module github.nu diff --git a/pkgs/nu-git-manager-sugar/package.nuon b/pkgs/nu-git-manager-sugar/nupm.nuon similarity index 92% rename from pkgs/nu-git-manager-sugar/package.nuon rename to pkgs/nu-git-manager-sugar/nupm.nuon index 974b12fa..bee1672d 100644 --- a/pkgs/nu-git-manager-sugar/package.nuon +++ b/pkgs/nu-git-manager-sugar/nupm.nuon @@ -1,6 +1,6 @@ { name: "nu-git-manager-sugar" - version: 0.4.0 + version: 0.5.0 description: "A collection of extra Nushell tools to manage `git` repositories." documentation: "https://github.com/amtoine/nu-git-manager/blob/main/README.md" maintainers: [ @@ -9,7 +9,7 @@ ] license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE" dependencies: { - nushell: 0.88.1 + nushell: 0.89.0 git: 2.40.1 optionals: { "sugar gh": { diff --git a/pkgs/nu-git-manager-sugar/tests/git.nu b/pkgs/nu-git-manager-sugar/tests/git.nu index af15a2ed..fbd1f552 100644 --- a/pkgs/nu-git-manager-sugar/tests/git.nu +++ b/pkgs/nu-git-manager-sugar/tests/git.nu @@ -11,7 +11,7 @@ use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/ git [ "gm repo branch wipe" "gm repo compare" ] -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"] +use ../../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"] use ../../../tests/common/setup.nu [get-random-test-dir] def --env init-repo-and-cd-into []: nothing -> path { @@ -369,18 +369,18 @@ export def branch-compare [] { } export module prompt { - use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu [ + use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib git [ get-revision, git-action ] - use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu [ + use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib prompt [ get-left-prompt ] - use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/style.nu [ + use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib style [ simplify-path ] def "assert revision" [expected: record] { - let actual = get-revision --short-hash true + let actual = get-revision --short-hash assert equal $actual $expected } diff --git a/pkgs/nu-git-manager-sugar/tests/mod.nu b/pkgs/nu-git-manager-sugar/tests/mod.nu index 188dfe7c..cfe8a2d9 100644 --- a/pkgs/nu-git-manager-sugar/tests/mod.nu +++ b/pkgs/nu-git-manager-sugar/tests/mod.nu @@ -3,6 +3,8 @@ use std assert use ../../../tests/common/import.nu ["assert imports"] use ../../../tests/common/setup.nu [get-random-test-dir] +export module git.nu + const MODULE = "nu-git-manager-sugar" export module imports { diff --git a/pkgs/nu-git-manager/nu-git-manager/completions/nu-complete.nu b/pkgs/nu-git-manager/nu-git-manager/completions.nu similarity index 100% rename from pkgs/nu-git-manager/nu-git-manager/completions/nu-complete.nu rename to pkgs/nu-git-manager/nu-git-manager/completions.nu diff --git a/pkgs/nu-git-manager/nu-git-manager/error/error.nu b/pkgs/nu-git-manager/nu-git-manager/error.nu similarity index 100% rename from pkgs/nu-git-manager/nu-git-manager/error/error.nu rename to pkgs/nu-git-manager/nu-git-manager/error.nu diff --git a/pkgs/nu-git-manager/nu-git-manager/fs/cache.nu b/pkgs/nu-git-manager/nu-git-manager/fs/cache.nu index 02f20794..264fa637 100644 --- a/pkgs/nu-git-manager/nu-git-manager/fs/cache.nu +++ b/pkgs/nu-git-manager/nu-git-manager/fs/cache.nu @@ -1,5 +1,4 @@ use path.nu "path sanitize" -use ../git/repo.nu [is-grafted] # get the path to the cache of the local store of repos # diff --git a/pkgs/nu-git-manager/nu-git-manager/fs/mod.nu b/pkgs/nu-git-manager/nu-git-manager/fs/mod.nu new file mode 100644 index 00000000..d221af7b --- /dev/null +++ b/pkgs/nu-git-manager/nu-git-manager/fs/mod.nu @@ -0,0 +1,4 @@ +export module cache.nu +export module dir.nu +export module path.nu +export module store.nu diff --git a/pkgs/nu-git-manager/nu-git-manager/git/mod.nu b/pkgs/nu-git-manager/nu-git-manager/git/mod.nu new file mode 100644 index 00000000..6247e39b --- /dev/null +++ b/pkgs/nu-git-manager/nu-git-manager/git/mod.nu @@ -0,0 +1,2 @@ +export module repo.nu +export module url.nu diff --git a/pkgs/nu-git-manager/nu-git-manager/git/repo.nu b/pkgs/nu-git-manager/nu-git-manager/git/repo.nu index 5d3995d9..dc07eeaa 100644 --- a/pkgs/nu-git-manager/nu-git-manager/git/repo.nu +++ b/pkgs/nu-git-manager/nu-git-manager/git/repo.nu @@ -1,4 +1,4 @@ -use ../error/error.nu [throw-error] +use ../error.nu [throw-error] # tell if a local repository has been grafted # diff --git a/pkgs/nu-git-manager/nu-git-manager/git/url.nu b/pkgs/nu-git-manager/nu-git-manager/git/url.nu index 714144d2..a4ca65da 100644 --- a/pkgs/nu-git-manager/nu-git-manager/git/url.nu +++ b/pkgs/nu-git-manager/nu-git-manager/git/url.nu @@ -1,4 +1,4 @@ -use ../fs/path.nu "path sanitize" +use ../fs path "path sanitize" # parse the URL of a Git repo # @@ -28,8 +28,8 @@ export def parse-git-url []: string -> record nothing { @@ -109,7 +114,7 @@ export def "gm clone" [ } } - let urls = get-fetch-push-urls $repository $fetch $push $ssh + let urls = get-fetch-push-urls $repository ($fetch | default "") ($push | default "") $ssh mut args = [$urls.fetch $local_path --origin $remote] if $depth != null { @@ -134,7 +139,7 @@ export def "gm clone" [ } } - ^git clone $args + ^git clone ...$args ^git -C $local_path remote set-url $remote $urls.fetch ^git -C $local_path remote set-url $remote --push $urls.push diff --git a/pkgs/nu-git-manager/package.nuon b/pkgs/nu-git-manager/nupm.nuon similarity index 90% rename from pkgs/nu-git-manager/package.nuon rename to pkgs/nu-git-manager/nupm.nuon index e17af38f..9fa98953 100644 --- a/pkgs/nu-git-manager/package.nuon +++ b/pkgs/nu-git-manager/nupm.nuon @@ -1,6 +1,6 @@ { name: "nu-git-manager" - version: 0.4.0 + version: 0.5.0 description: "A collection of Nushell tools to manage `git` repositories." documentation: "https://github.com/amtoine/nu-git-manager/blob/main/README.md" maintainers: [ @@ -9,7 +9,7 @@ ] license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE" dependencies: { - nushell: 0.88.1 + nushell: 0.89.0 git: 2.40.1 } type: "module" diff --git a/pkgs/nu-git-manager/tests/gm.nu b/pkgs/nu-git-manager/tests/gm.nu index ceb9f978..d27b0127 100644 --- a/pkgs/nu-git-manager/tests/gm.nu +++ b/pkgs/nu-git-manager/tests/gm.nu @@ -1,7 +1,7 @@ use std assert -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"] -use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [list-remotes] +use ../../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"] +use ../../../pkgs/nu-git-manager/nu-git-manager/git repo [list-remotes] use ../../../pkgs/nu-git-manager/nu-git-manager/ * use ../../../tests/common/setup.nu [get-random-test-dir] diff --git a/pkgs/nu-git-manager/tests/mod.nu b/pkgs/nu-git-manager/tests/mod.nu index e9f1f63a..f3ea3b64 100644 --- a/pkgs/nu-git-manager/tests/mod.nu +++ b/pkgs/nu-git-manager/tests/mod.nu @@ -1,25 +1,27 @@ use std assert -use ../../../pkgs/nu-git-manager/nu-git-manager/git/url.nu [ +use ../../../pkgs/nu-git-manager/nu-git-manager/git url [ parse-git-url, get-fetch-push-urls ] -use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [ +use ../../../pkgs/nu-git-manager/nu-git-manager/git repo [ is-grafted, get-root-commit, list-remotes ] -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/store.nu [ +use ../../../pkgs/nu-git-manager/nu-git-manager/fs store [ get-repo-store-path, list-repos-in-store ] -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/cache.nu [ +use ../../../pkgs/nu-git-manager/nu-git-manager/fs cache [ get-repo-store-cache-path, check-cache-file, add-to-cache, remove-from-cache, open-cache, save-cache, clean-cache-dir ] -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu [ +use ../../../pkgs/nu-git-manager/nu-git-manager/fs path [ "path sanitize", "path remove-prefix", "path remove-trailing-path-sep" ] -use ../../../pkgs/nu-git-manager/nu-git-manager/fs/dir.nu [clean-empty-directories-rec] +use ../../../pkgs/nu-git-manager/nu-git-manager/fs dir [clean-empty-directories-rec] use ../../../tests/common/setup.nu [get-random-test-dir] +export module gm.nu + export module path { export def sanitization [] { assert equal ('\foo\bar' | path sanitize) "/foo/bar" @@ -43,15 +45,15 @@ export def git-url-parsing [] { let cases = [ [input, host, owner, group, repo]; - ["https://github.com/foo/bar", "github.com", "foo", null, "bar"], - ["https://github.com/foo/bar.git", "github.com", "foo", null, "bar"], - ["https://github.com/foo/bar/tree/branch/file", "github.com", "foo", null, "bar"], - ["ssh://github.com/foo/bar", "github.com", "foo", null, "bar"], - ["git@github.com:foo/bar", "github.com", "foo", null, "bar"], - ["https://gitlab.com/foo/bar", "gitlab.com", "foo", null, "bar"], - ["git@gitlab.com:foo/bar", "gitlab.com", "foo", null, "bar"], + ["https://github.com/foo/bar", "github.com", "foo", "", "bar"], + ["https://github.com/foo/bar.git", "github.com", "foo", "", "bar"], + ["https://github.com/foo/bar/tree/branch/file", "github.com", "foo", "", "bar"], + ["ssh://github.com/foo/bar", "github.com", "foo", "", "bar"], + ["git@github.com:foo/bar", "github.com", "foo", "", "bar"], + ["https://gitlab.com/foo/bar", "gitlab.com", "foo", "", "bar"], + ["git@gitlab.com:foo/bar", "gitlab.com", "foo", "", "bar"], ["git@gitlab.com:foo/bar/baz/brr", "gitlab.com", "foo", "bar/baz", "brr"], - ["git://git.suckless.org/st", "git.suckless.org", null, null, "st"], + ["git://git.suckless.org/st", "git.suckless.org", "", "", "st"], ] for case in $cases { @@ -202,7 +204,7 @@ export def cache-manipulation [] { root_hash: "", } - def "assert cache" [cache: list]: nothing -> nothing { + def "assert cache" [cache: list]: nothing -> nothing { let actual = open-cache $CACHE | update path { path remove-prefix (pwd | path sanitize) } let expected = $cache | each {|it| diff --git a/tests/common/setup.nu b/tests/common/setup.nu index 476e2588..ae2f4d42 100644 --- a/tests/common/setup.nu +++ b/tests/common/setup.nu @@ -1,4 +1,4 @@ -use ../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"] +use ../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"] # return the path to a random test directory # diff --git a/toolkit.nu b/toolkit.nu index 7ec398d6..fcb2dc62 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -2,7 +2,7 @@ use std repeat # NOTE: this will likely get replaced by Nupm workspaces in the future def list-modules-of-workspace []: nothing -> list { - ls pkgs/**/package.nuon + ls pkgs/**/nupm.nuon | insert pkg {|it| open $it.name | get name } | each {|it| $it.name | path dirname | path join $it.pkg } } @@ -114,11 +114,13 @@ export def "run" [ } let sugar_imports = if $sugar != null { - $sugar | each { $"use ./src/nu-git-manager-sugar ($in) *" } + $sugar | each { $"use ./pkgs/nu-git-manager-sugar/nu-git-manager-sugar ($in) *" } } else { [] } - let imports = $sugar_imports | prepend "use ./src/nu-git-manager *" | str join "\n" + let imports = $sugar_imports + | prepend "use ./pkgs/nu-git-manager/nu-git-manager *" + | str join "\n" let nu_args = [ --env-config $env_file