Skip to content

Commit d4969c9

Browse files
authored
chore: make the tag reference name compitable (#54)
* fix: cannot get the home dir on windows * chore: make the tag reference name compitable --------- Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
1 parent 482c657 commit d4969c9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cmd/checkout.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ func (o *checkoutOption) runE(c *cobra.Command, args []string) (err error) {
118118
}
119119

120120
if o.tag != "" {
121+
var tagRef plumbing.ReferenceName
122+
if strings.HasPrefix(o.tag, "refs/tags/") {
123+
tagRef = plumbing.ReferenceName(o.tag)
124+
} else {
125+
tagRef = plumbing.NewTagReferenceName(o.tag)
126+
}
127+
121128
if err = wd.Checkout(&git.CheckoutOptions{
122-
Branch: plumbing.NewTagReferenceName(o.tag),
129+
Branch: tagRef,
123130
}); err != nil {
124131
err = fmt.Errorf("unable to checkout git tag: %s, error: %v", o.tag, err)
125132
return

0 commit comments

Comments
 (0)