mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-22 13:53:07 +03:00
Add tide_git_truncation_length (#221)
This commit is contained in:
parent
fa3393f362
commit
055f298b12
@ -1,12 +1,14 @@
|
||||
function _tide_item_git
|
||||
set -l location $_tide_location_color(git branch --show-current 2>/dev/null) || return
|
||||
# --quiet = don't error if there are no commits
|
||||
git rev-parse --quiet --git-dir --is-inside-git-dir --short HEAD | read -l --line git_dir inside_git_dir sha
|
||||
|
||||
if test -z "$location" # Default to branch, then tag, then sha
|
||||
# get last tag b/c they are listed in alphabet order, so more specific 5.0.1 is after 5
|
||||
set location '#'$_tide_location_color(git tag --points-at HEAD)[-1]
|
||||
test -z "$location" && set location @$_tide_location_color$sha
|
||||
if git branch --show-current 2>/dev/null | string replace -r "(.{$tide_git_truncation_length})..*" '$1…' | read -l location
|
||||
set location $_tide_location_color$location
|
||||
git rev-parse --git-dir --is-inside-git-dir | read -f --line git_dir inside_git_dir
|
||||
else if test $pipestatus[1] != 0
|
||||
return
|
||||
else
|
||||
# --quiet = don't error if there are no commits
|
||||
git rev-parse --git-dir --is-inside-git-dir --quiet --short HEAD | read -f --line git_dir inside_git_dir sha
|
||||
git tag --points-at HEAD | string replace -r "(.{$tide_git_truncation_length})..*" '$1…' | read location &&
|
||||
set location '#'$_tide_location_color$location || set location @$_tide_location_color$sha
|
||||
end
|
||||
|
||||
# Operation
|
||||
|
@ -29,6 +29,7 @@ tide_git_color_stash $_tide_color_green
|
||||
tide_git_color_untracked $_tide_color_light_blue
|
||||
tide_git_color_upstream $_tide_color_green
|
||||
tide_git_icon
|
||||
tide_git_truncation_length 24
|
||||
tide_go_bg_color 444444
|
||||
tide_go_color 00ACD7
|
||||
tide_go_icon
|
||||
|
@ -29,6 +29,7 @@ tide_git_color_stash $_tide_color_green
|
||||
tide_git_color_untracked $_tide_color_light_blue
|
||||
tide_git_color_upstream $_tide_color_green
|
||||
tide_git_icon
|
||||
tide_git_truncation_length 24
|
||||
tide_go_bg_color normal
|
||||
tide_go_color 00ACD7
|
||||
tide_go_icon
|
||||
|
@ -29,6 +29,7 @@ tide_git_color_stash 000000
|
||||
tide_git_color_untracked 000000
|
||||
tide_git_color_upstream 000000
|
||||
tide_git_icon
|
||||
tide_git_truncation_length 24
|
||||
tide_go_bg_color 00ACD7
|
||||
tide_go_color 000000
|
||||
tide_go_icon
|
||||
|
@ -56,6 +56,16 @@ _git commit -am 'Append hello to foo'
|
||||
_git checkout HEAD~
|
||||
_git_item # CHECK: {{@\w*}}
|
||||
|
||||
# Long branches
|
||||
_git checkout main
|
||||
_git checkout -b very_long_branch_name
|
||||
set tide_git_truncation_length 10
|
||||
_git_item # CHECK: very_long_…
|
||||
|
||||
# Branch same length as tide_git_truncation_length
|
||||
_git checkout -b very_long_
|
||||
_git_item # CHECK: very_long_
|
||||
|
||||
# -------- bare repo test --------
|
||||
cd $dir/bare-repo
|
||||
_git init --bare
|
||||
|
Loading…
Reference in New Issue
Block a user