Merge branch 'fix-submodules'

This commit is contained in:
Ilan Cosman 2022-04-22 13:06:40 -07:00
commit 11ac7bacfe
3 changed files with 31 additions and 11 deletions

View File

@ -1,14 +1,14 @@
function _tide_item_git
if git branch --show-current 2>/dev/null | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read -l location
git rev-parse --git-dir | read -f git_dir
git rev-parse --git-dir --is-inside-git-dir | read -fL git_dir inside_git_dir
set location $_tide_location_color$location
else if test $pipestatus[1] != 0
return
else if git tag --points-at HEAD | string replace -r "(.{$tide_git_truncation_length}).+" '$1…' | read location
git rev-parse --git-dir | read -f git_dir
git rev-parse --git-dir --is-inside-git-dir | read -fL git_dir inside_git_dir
set location '#'$_tide_location_color$location
else
git rev-parse --git-dir --short HEAD | read -fL git_dir location
git rev-parse --git-dir --is-inside-git-dir --short HEAD | read -fL git_dir inside_git_dir location
set location @$_tide_location_color$location
end
@ -38,11 +38,12 @@ function _tide_item_git
end
# Git status/stash + Upstream behind/ahead
test $inside_git_dir = true && set -l _set_dir_opt -C $git_dir/..
# Suppress errors in case we are in a bare repo or there is no upstream
git_info=(git -C $git_dir/.. --no-optional-locks status --porcelain 2>/dev/null) \
git_info=(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 -C $git_dir/.. stash list 2>/dev/null | count
"$(git $_set_dir_opt stash list 2>/dev/null | count
string match -r ^UU $git_info | count
string match -r ^[ADMR]. $git_info | count
string match -r ^.[ADMR] $git_info | count

View File

@ -1,16 +1,16 @@
function _tide_sub_bug-report
argparse c/clean v/verbose -- $argv
set -l fish_path (status fish-path)
if set -q _flag_clean
HOME=(mktemp -d) fish --init-command "curl --silent \
HOME=(mktemp -d) $fish_path --init-command "curl --silent \
https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish |
source && fisher install ilancosman/tide@v5"
else if set -q _flag_verbose
set --long | string match -r "^_?tide.*" | # Get only tide variables
string match -r --invert "^_tide_prompt_var.*" # Remove _tide_prompt_var
else
set -l fish_path (status fish-path)
set -l fish_version ($fish_path --version | string match -r "fish, version (\d\.\d\.\d)")[2]
_tide_check_version Fish fish-shell/fish-shell "(\d\.\d\.\d)" $fish_version || return
@ -29,7 +29,7 @@ function _tide_sub_bug-report
"Tide does not work with oh-my-fish installed." \
"Please uninstall it before submitting a bug report." || return
set -l fish_startup_time (fish -ic "time fish -c exit" 2>&1 |
set -l fish_startup_time ($fish_path -ic "time $fish_path -c exit" 2>|
string match -r "Executed in(.*)fish" | string trim)[2]
read --local --prompt-str "What operating system are you using? (e.g Ubuntu 20.04): " os

View File

@ -10,7 +10,7 @@ end
# Create directory
set -l dir (mktemp -d)
mkdir -p $dir/{normal-repo, bare-repo}
mkdir -p $dir/{normal-repo, bare-repo, submodule-repo}
# Not in git repo
cd $dir
@ -30,7 +30,7 @@ _git_item # CHECK: main
cd ..
# Untracked
touch foo
echo >foo
_git_item # CHECK: main ?1
# Staged
@ -72,4 +72,23 @@ _git init --bare
_git branch -m main
_git_item # CHECK: main
# ------ submodule repo test ------
cd $dir/submodule-repo
_git init
_git branch -m main
_git submodule add $dir/normal-repo
_git_item # CHECK: main +2
cd normal-repo
_git_item # CHECK: very_long_
cd ..
echo >new_main_git_file
_git_item # CHECK: main +2 ?1
echo >normal-repo/new_submodule_file
_git_item # CHECK: main +2 !1 ?1
cd normal-repo
_git_item # CHECK: very_long_ ?1
# ------ cleanup ------
rm -r $dir