2024-05-31 20:15:41: merge [master:bc5555706dc845c45735adf8a7a18886cc83d5b7];

This commit is contained in:
txix committed 2024-05-31 20:15:41 +03:00
1 parent 13803ab804
commit 63ad9bb620
3 files changed
+15 -4

No files matched your search

+1 -1
View File
@@ -1 +1 @@
3.1.1
3.2.0
+2
View File
@@ -1,3 +1,5 @@
### v3.2.0
* добавлена поддержка тегов для `gitget`
### v3.1.1
* добавлена совместимость isp-config-service 3.x.x
### v2.2.3
+12 -3
View File
@@ -3,6 +3,7 @@ package command
import (
"io"
"os"
"regexp"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
@@ -12,6 +13,10 @@ import (
"github.com/urfave/cli/v2"
)
var (
semverRegexp = regexp.MustCompile("v([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$")
)
func GitGet() *cli.Command {
return &cli.Command{
Name: "gitget",
@@ -36,9 +41,13 @@ func GitGet() *cli.Command {
}
if commit != "" {
err = tree.Checkout(&git.CheckoutOptions{
Hash: plumbing.NewHash(commit),
})
checkoutOpts := git.CheckoutOptions{}
if semverRegexp.MatchString(commit) {
checkoutOpts.Branch = plumbing.NewTagReferenceName(commit)
} else {
checkoutOpts.Hash = plumbing.NewHash(commit)
}
err = tree.Checkout(&checkoutOpts)
if err != nil {
return errors.WithMessagef(err, "checkout: %s", commit)
}