Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

nushell/tests/git-scope-guard.sh

Raw
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
cd "$repo_root"

actual="$(grep -RInE '(^|[[:space:]])(\^git|run-external git|aka [^[:space:]]+ git($|[[:space:]]))' nushell --include='*.nu' \
  | sed 's#^./##' \
  | sort)"

expected='nushell/gen-aliases.nu:38:aka g git
nushell/modules/git.nu:32:        ^git ...$args | complete
nushell/modules/git.nu:34:        ^git -C $cwd ...$args | complete
nushell/modules/git.nu:421:    ^git -C $source diff --binary --cached | save --force $patches.staged
nushell/modules/git.nu:422:    ^git -C $source diff --binary | save --force $patches.unstaged
nushell/modules/sy.nu:17:	run-external git ...$git_add_dotfiles
nushell/modules/sy.nu:18:	try { run-external git ...$git_commit_dotfiles }
nushell/modules/sy.nu:19:	run-external git ...$git_push_dotfiles
nushell/modules/sy.nu:26:	run-external git ...$git_pull_dotfiles
nushell/modules/sy.nu:5:	run-external git ...$git_status_dotfiles'

if [ "$actual" != "$expected" ]; then
  echo 'FAIL: Nushell git caller scope changed' >&2
  echo '--- expected ---' >&2
  printf '%s\n' "$expected" >&2
  echo '--- actual ---' >&2
  printf '%s\n' "$actual" >&2
  exit 1
fi

printf 'ok git-scope-guard\n'