Skip to content

Commit

Permalink
chore: make the tag reference name compitable (#54)
Browse files Browse the repository at this point in the history
* fix: cannot get the home dir on windows

* chore: make the tag reference name compitable

---------

Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
  • Loading branch information
LinuxSuRen and LinuxSuRen committed Apr 22, 2024
1 parent 482c657 commit d4969c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,15 @@ func (o *checkoutOption) runE(c *cobra.Command, args []string) (err error) {
}

if o.tag != "" {
var tagRef plumbing.ReferenceName
if strings.HasPrefix(o.tag, "refs/tags/") {
tagRef = plumbing.ReferenceName(o.tag)
} else {
tagRef = plumbing.NewTagReferenceName(o.tag)
}

if err = wd.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewTagReferenceName(o.tag),
Branch: tagRef,
}); err != nil {
err = fmt.Errorf("unable to checkout git tag: %s, error: %v", o.tag, err)
return
Expand Down

0 comments on commit d4969c9

Please sign in to comment.