Fix error message when git status is massive, add regression test (fixes #394)

This commit is contained in:
Ilan Cosman 2023-03-28 17:16:06 -07:00
parent 03fea2fcf0
commit 7f11fcbe90
3 changed files with 15 additions and 3 deletions

View File

@ -11,6 +11,10 @@
- Git branch truncation has reverted to keeping the beginning
- Use `set tide_git_truncation_strategy l` to keep the end instead
### Bug fixes
- Fix an error message when `git status` produces a huge amount of information ([#394][])
## [v5.5.1][] (Sep 14 2022)
### Bug fixes
@ -524,6 +528,7 @@
[#343]: https://github.com/IlanCosman/tide/pull/343
[#346]: https://github.com/IlanCosman/tide/issues/346
[#373]: https://github.com/IlanCosman/tide/pull/373
[#394]: https://github.com/IlanCosman/tide/issues/394
[prettier action]: https://github.com/actionsx/prettier
[super-linter]: https://github.com/github/super-linter
[v1.0.0]: https://github.com/IlanCosman/tide/tree/v1.0.0

View File

@ -40,8 +40,8 @@ function _tide_item_git
# Git status/stash + Upstream behind/ahead
test $in_gdir = true && set -l _set_dir_opt -C $gdir/..
# Suppress errors in case we are in a bare repo or there is no upstream
stat=(git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null) \
string match -qr '(0|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
set -l stat (git $_set_dir_opt --no-optional-locks status --porcelain 2>/dev/null)
string match -qr '(0|(?<stash>.*))\n(0|(?<conflicted>.*))\n(0|(?<staged>.*))
(0|(?<dirty>.*))\n(0|(?<untracked>.*))(\n(0|(?<behind>.*))\t(0|(?<ahead>.*)))?' \
"$(git $_set_dir_opt stash list 2>/dev/null | count
string match -r ^UU $stat | count

View File

@ -11,7 +11,7 @@ end
# Create directory
set -l dir (mktemp -d)
mkdir -p $dir/{normal-repo, bare-repo, submodule-repo}
mkdir -p $dir/{normal-repo, bare-repo, submodule-repo, massive-status-repo}
# Not in git repo
cd $dir
@ -95,5 +95,12 @@ _git_item # CHECK: main +2 !1 ?1
cd normal-repo
_git_item # CHECK: 10charhere ?1
# --- Massive git status ---
cd $dir/massive-status-repo
_git init
_git branch -m main
mock git "--no-optional-locks status --porcelain" "string repeat -n100000 'D some-file-name'\n"
_git_item # CHECK: main +100000
# ------ cleanup ------
command rm -r $dir