Skip to content
This repository was archived by the owner on Jun 30, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/nupm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ jobs:
use toolkit.nu
toolkit test --verbose
"

# const NUSHELL_VERSION = "0.89.0"
# const NUSHELL_ARCH = "x86_64-unknown-linux-gnu"
#
# let nushell_build = $"nu-($NUSHELL_VERSION)-($NUSHELL_ARCH)"
# http get https://github.com/nushell/nushell/releases/download/($NUSHELL_VERSION)/($nushell_build).tar.gz
# | save -f -p /tmp/nu.tar.gz
# tar -xvf /tmp/nu.tar.gz --directory /tmp
# ^$nu.current-exe --commands $"register /tmp/($nushell_build)/nu_plugin_gstat"
42 changes: 22 additions & 20 deletions pkgs/nu-git-manager-sugar/nu-git-manager-sugar/extra.nu
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use nu-git-manager [ "gm list" ]

# get a full report about the local store of repositories
#
# ## Examples
Expand Down Expand Up @@ -39,34 +41,34 @@ export def "gm report" []: nothing -> table<name: string, branch: string, remote
print --no-newline $"(ansi erase_line)[($it.index + 1) / ($repos | length)]: ($it.item)\r"
{ path: $it.item } | merge (gstat $it.item)
}
| insert index {(
$in.idx_added_staged
+ $in.idx_modified_staged
+ $in.idx_deleted_staged
+ $in.idx_renamed
+ $in.idx_type_changed
| insert index {|it| (
$it.idx_added_staged
+ $it.idx_modified_staged
+ $it.idx_deleted_staged
+ $it.idx_renamed
+ $it.idx_type_changed
)}
| insert worktree {(
$in.wt_untracked
+ $in.wt_modified
+ $in.wt_deleted
+ $in.wt_type_changed
+ $in.wt_renamed
| insert worktree { |it| (
$it.wt_untracked
+ $it.wt_modified
+ $it.wt_deleted
+ $it.wt_type_changed
+ $it.wt_renamed
)}
| select repo_name branch remote tag index ignored conflicts ahead behind worktree stashes
| rename --column {repo_name: name}
| update remote {|it| $it.remote | str replace --regex $'/($it.branch)$' '' }
| update tag { if $in == "no_tag" { null } else { $in } }
| update remote { if $in == "" { null } else { $in } }
| insert clean {
| insert clean {|it|
(
$in.index
+ $in.ignored
+ $in.conflicts
+ $in.ahead
+ $in.behind
+ $in.worktree
+ $in.stashes
$it.index
+ $it.ignored
+ $it.conflicts
+ $it.ahead
+ $it.behind
+ $it.worktree
+ $it.stashes
) == 0
}
}
15 changes: 15 additions & 0 deletions pkgs/nu-git-manager-sugar/tests/extra.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use ../../../tests/common/setup.nu [run-with-env]

use ../../../pkgs/nu-git-manager/nu-git-manager/ ["gm clone", "gm update-cache"]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/ extra ["gm report"]

export def report [] {
run-with-env {
use std assert

gm update-cache
gm clone https://github.com/amtoine/nu-git-manager --depth 1

assert equal (gm report) []
}
}
1 change: 1 addition & 0 deletions pkgs/nu-git-manager-sugar/tests/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ../../../tests/common/import.nu ["assert imports"]
use ../../../tests/common/setup.nu [get-random-test-dir]

export module git.nu
export module extra.nu

const MODULE = "nu-git-manager-sugar"

Expand Down
19 changes: 1 addition & 18 deletions pkgs/nu-git-manager/tests/gm.nu
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,9 @@ 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]
use ../../../tests/common/setup.nu [run-with-env]
use ../../../tests/common/import.nu ["assert imports"]

def run-with-env [code: closure, --prepare-cache] {
let TEST_ENV_BASE = get-random-test-dir

let TEST_ENV = {
GIT_REPOS_HOME: ($TEST_ENV_BASE | path join "repos"),
GIT_REPOS_CACHE: ($TEST_ENV_BASE | path join "repos.cache"),
}

if $prepare_cache {
with-env $TEST_ENV { gm update-cache }
}

with-env $TEST_ENV $code

rm --recursive --force --verbose $TEST_ENV_BASE
}

export def error-with-empty-store [] {
run-with-env {
# NOTE: the full error:
Expand Down
18 changes: 18 additions & 0 deletions tests/common/setup.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ../../pkgs/nu-git-manager/nu-git-manager/fs path ["path sanitize"]
use ../../pkgs/nu-git-manager/nu-git-manager/ [ "gm update-cache" ]

# return the path to a random test directory
#
Expand All @@ -14,3 +15,20 @@ export def get-random-test-dir [--no-sanitize]: nothing -> path {
$test_dir
}
}

export def run-with-env [code: closure, --prepare-cache] {
let TEST_ENV_BASE = get-random-test-dir

let TEST_ENV = {
GIT_REPOS_HOME: ($TEST_ENV_BASE | path join "repos"),
GIT_REPOS_CACHE: ($TEST_ENV_BASE | path join "repos.cache"),
}

if $prepare_cache {
with-env $TEST_ENV { gm update-cache }
}

with-env $TEST_ENV $code

rm --recursive --force --verbose $TEST_ENV_BASE
}