Skip to content

Commit a2e5259

Browse files
authored
feat: add annotated tags support for tag command (#42)
1 parent 0a87d53 commit a2e5259

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

conf.d/gitnow.fish

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ function tag -d "Gitnow: Tag commits following Semver"
495495
set -l v_preminor
496496
set -l v_prepatch
497497

498+
set -l opts
499+
498500
# NOTE: this function only gets the latest *Semver release version* but no suffixed ones or others
499501
set -l v_latest (__gitnow_get_latest_semver_release_tag)
500502

@@ -506,6 +508,8 @@ function tag -d "Gitnow: Tag commits following Semver"
506508
set v_minor $v
507509
case -z --patch
508510
set v_patch $v
511+
case -a --annotate
512+
set opts $opts $v
509513

510514
# TODO: pre-release versions are not supported yet
511515
# case -a --premajor
@@ -537,6 +541,7 @@ function tag -d "Gitnow: Tag commits following Semver"
537541
echo " -y --minor Tag auto-incrementing a minor version number"
538542
echo " -z --patch Tag auto-incrementing a patch version number"
539543
echo " -l --latest Show only the latest Semver release tag version (no suffixed ones or others)"
544+
echo " -a --annotate Create as annotated tag"
540545
echo " -h --help Show information about the options for this command"
541546

542547
# TODO: pre-release versions are not supported yet
@@ -552,15 +557,15 @@ function tag -d "Gitnow: Tag commits following Semver"
552557
end
553558

554559
# List all tags in a lexicographic order and treating tag names as versions
555-
if test -z $argv
560+
if test -z "$argv"
556561
__gitnow_get_tags_ordered
557562
return
558563
end
559564

560565
# Major version tags
561566
if test -n "$v_major"
562567
if not test -n "$v_latest"
563-
command git tag v1.0.0
568+
command git tag $opts v1.0.0
564569
echo "First major tag \"v1.0.0\" was created."
565570
return
566571
else
@@ -577,7 +582,7 @@ function tag -d "Gitnow: Tag commits following Semver"
577582
set x (__gitnow_increment_number $x)
578583
set -l xyz "$prefix$x.0.0"
579584

580-
command git tag $xyz
585+
command git tag $opts $xyz
581586
echo "Major tag \"$xyz\" was created."
582587
return
583588
end
@@ -587,7 +592,7 @@ function tag -d "Gitnow: Tag commits following Semver"
587592
# Minor version tags
588593
if test -n "$v_minor"
589594
if not test -n "$v_latest"
590-
command git tag v0.1.0
595+
command git tag $opts v0.1.0
591596
echo "First minor tag \"v0.1.0\" was created."
592597
return
593598
else
@@ -605,7 +610,7 @@ function tag -d "Gitnow: Tag commits following Semver"
605610
set y (__gitnow_increment_number $y)
606611
set -l xyz "$prefix$x.$y.0"
607612

608-
command git tag $xyz
613+
command git tag $opts $xyz
609614
echo "Minor tag \"$xyz\" was created."
610615
return
611616
end
@@ -615,7 +620,7 @@ function tag -d "Gitnow: Tag commits following Semver"
615620
# Patch version tags
616621
if test -n "$v_patch"
617622
if not test -n "$v_latest"
618-
command git tag v0.0.1
623+
command git tag $opts v0.0.1
619624
echo "First patch tag \"v0.1.0\" was created."
620625
return
621626
else
@@ -637,7 +642,7 @@ function tag -d "Gitnow: Tag commits following Semver"
637642
set s (__gitnow_increment_number $s)
638643
set -l xyz "$prefix$x.$y.$s"
639644

640-
command git tag $xyz
645+
command git tag $opts $xyz
641646
echo "Patch tag \"$xyz\" was created."
642647
else
643648
echo "No patch version found."

0 commit comments

Comments
 (0)