From 908a0097d18111e626e6e2fe7163937dbe3ee1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 9 Apr 2023 22:18:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96git?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git.go | 14 +++++++++++++- go.mod | 11 +++++++++-- go.sum | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/git.go b/git.go index 3e9952d..ba8a6e8 100644 --- a/git.go +++ b/git.go @@ -20,7 +20,10 @@ import ( // Date : 20:09 2022/6/14 func Git(workDir string, gitCmdPath string) *git { if len(gitCmdPath) == 0 { - gitCmdPath = "git" + gitCmdPath, _ = Check("git") + if len(gitCmdPath) == 0 { + gitCmdPath = "git" + } } return &git{ workDir: workDir, @@ -222,3 +225,12 @@ func (g *git) Clone(repo string, saveDir string) *define.Result { } return Execute(g.workDir, g.gitCmdPath, param) } + +// Version 获取版本信息 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:15 2023/4/9 +func (g *git) Version() *define.Result { + return Execute(g.workDir, g.gitCmdPath, []string{"version"}) +} diff --git a/go.mod b/go.mod index e103b2e..177b254 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,20 @@ module git.zhangdeman.cn/zhangdeman/command -go 1.17 +go 1.20 require ( - git.zhangdeman.cn/zhangdeman/util v0.0.0-20220626081130-cbac0b676fb8 + git.zhangdeman.cn/zhangdeman/util v0.0.0-20230409110607-0a75d06083d1 gopkg.in/yaml.v3 v3.0.1 ) require ( + github.com/Jeffail/gabs v1.4.0 // indirect + github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect + github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect + github.com/go-ini/ini v1.67.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/tidwall/gjson v1.14.4 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index 2a4564f..2281731 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,26 @@ git.zhangdeman.cn/zhangdeman/util v0.0.0-20220626081130-cbac0b676fb8 h1:HTa2y2Fsh9q48f29I/V2LhVQ5Pai55ULP1Qj3qwhrOE= git.zhangdeman.cn/zhangdeman/util v0.0.0-20220626081130-cbac0b676fb8/go.mod h1:G2/OKMbEn89d+YUXQtv9Nlh0LGg14pOqDnbOgBTTRXY= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230409110607-0a75d06083d1 h1:EO1BYZ/6Wert33rIqS460622lRQDg7vQf1gnXoN9dhY= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20230409110607-0a75d06083d1/go.mod h1:KWUcgU0xtnmrGfb2tgdcwjnzp4HK+IT4ar3HdZoZA2g= +github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= +github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= +github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= +github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= +github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= +github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=