1
0
mirror of https://github.com/mbollmann/fishpkgs.git synced 2024-10-27 20:34:02 +00:00
mbollmann_fishpkgs/functions/git_branch_name.fish
2021-06-02 11:51:44 +02:00

16 lines
485 B
Fish

function git_branch_name -d "Get the name of the current Git branch, tag or sha1"
set -l branch_name (command git symbolic-ref --short HEAD 2>/dev/null)
if test -z "$branch_name"
set -l tag_name (command git describe --tags --exact-match HEAD 2>/dev/null)
if test -z "$tag_name"
command git rev-parse --short HEAD 2>/dev/null
else
printf "%s\n" "$tag_name"
end
else
printf "%s\n" "$branch_name"
end
end