Skip to content

Commit 25f74db

Browse files
author
yangyile
committed
伴随底层osexec的修改而修改代码
1 parent 6b2e495 commit 25f74db

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

git_up.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ else
4141
echo "$res"
4242
fi
4343
`
44-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
44+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
4545
if err != nil {
4646
return "", erero.Wro(err)
4747
}
@@ -63,7 +63,7 @@ echo "$res"
6363
commandBash := fmt.Sprintf(commandBashTemplate, regexp.QuoteMeta(prefix))
6464

6565
// 存在问题,就是标签是打在commit提交上面的,因此在相同的提交上打多个标签时,他们的时间是相同的,这时候取到的,有可能不是最新的那个标签
66-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
66+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
6767
if err != nil {
6868
return "", erero.Wro(err)
6969
}
@@ -85,7 +85,7 @@ echo "$res"
8585
commandBash := fmt.Sprintf(commandBashTemplate, regexp.QuoteMeta(regexpPattern))
8686

8787
// 存在问题,就是标签是打在commit提交上面的,因此在相同的提交上打多个标签时,他们的时间是相同的,这时候取到的,有可能不是最新的那个标签
88-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
88+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
8989
if err != nil {
9090
return "", erero.Wro(err)
9191
}
@@ -104,7 +104,7 @@ func (G *Gcm) GitCommitHash(refName string) (string, error) {
104104
// SortedGitTags 获取项目的标签列表,按时间从前到后排列。使用场景是仅仅观察标签,让用户自己想出下一个标签的序号,因此这里只返回个字符串就行
105105
func (G *Gcm) SortedGitTags() (string, error) {
106106
const commandBash = "git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags"
107-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
107+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
108108
if err != nil {
109109
return "", erero.Wro(err)
110110
}
@@ -114,7 +114,7 @@ func (G *Gcm) SortedGitTags() (string, error) {
114114
// GetTopPath 获取 git 项目的根目录
115115
func (G *Gcm) GetTopPath() (string, error) {
116116
const commandBash = "git rev-parse --show-toplevel"
117-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
117+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
118118
if err != nil {
119119
return "", erero.Wro(err)
120120
}
@@ -124,7 +124,7 @@ func (G *Gcm) GetTopPath() (string, error) {
124124
// GetGitDirAbsPath 获取 git 项目的 .git 目录的绝对路径(如 "/home/user/project/.git")
125125
func (G *Gcm) GetGitDirAbsPath() (string, error) {
126126
const commandBash = "git rev-parse --absolute-git-dir" // 这里不要使用 git rev-parse --git-dir 稍微有点不好用
127-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
127+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
128128
if err != nil {
129129
return "", erero.Wro(err)
130130
}
@@ -134,7 +134,7 @@ func (G *Gcm) GetGitDirAbsPath() (string, error) {
134134
// GetSubPathToRoot 获取从当前目录到 git 项目根目录的相对路径(如 "../",如果在根目录则为空字符串)
135135
func (G *Gcm) GetSubPathToRoot() (string, error) {
136136
const commandBash = "git rev-parse --show-cdup"
137-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
137+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
138138
if err != nil {
139139
return "", erero.Wro(err)
140140
}
@@ -144,7 +144,7 @@ func (G *Gcm) GetSubPathToRoot() (string, error) {
144144
// GetSubPath 获取从 git 项目根目录到当前目录的相对路径(如 "subdir",如果在根目录则为空字符串)
145145
func (G *Gcm) GetSubPath() (string, error) {
146146
const commandBash = "git rev-parse --show-prefix"
147-
output, err := G.execConfig.ShallowClone().WithBash().Exec(strings.TrimSpace(commandBash))
147+
output, err := G.execConfig.NewConfig().WithBash().Exec(strings.TrimSpace(commandBash))
148148
if err != nil {
149149
return "", erero.Wro(err)
150150
}

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ go 1.22.8
55
require (
66
github.com/pkg/errors v0.9.1
77
github.com/stretchr/testify v1.10.0
8-
github.com/yyle88/erero v1.0.20
9-
github.com/yyle88/eroticgo v0.0.3
10-
github.com/yyle88/osexec v0.0.27
8+
github.com/yyle88/erero v1.0.21
9+
github.com/yyle88/eroticgo v0.0.4
10+
github.com/yyle88/osexec v0.0.31
1111
github.com/yyle88/osexistpath v0.0.17
1212
github.com/yyle88/rese v0.0.10
1313
github.com/yyle88/runpath v1.0.23
14-
github.com/yyle88/zaplog v0.0.22
14+
github.com/yyle88/zaplog v0.0.24
1515
)
1616

1717
require (
1818
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1919
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
20-
github.com/yyle88/done v1.0.25 // indirect
21-
github.com/yyle88/must v0.0.21 // indirect
20+
github.com/yyle88/done v1.0.26 // indirect
21+
github.com/yyle88/must v0.0.25 // indirect
2222
github.com/yyle88/mutexmap v1.0.13 // indirect
2323
github.com/yyle88/printgo v1.0.5 // indirect
2424
github.com/yyle88/sure v0.0.38 // indirect
25-
github.com/yyle88/syntaxgo v0.0.48 // indirect
26-
github.com/yyle88/tern v0.0.7 // indirect
25+
github.com/yyle88/syntaxgo v0.0.52 // indirect
26+
github.com/yyle88/tern v0.0.8 // indirect
2727
go.uber.org/multierr v1.11.0 // indirect
2828
go.uber.org/zap v1.27.0 // indirect
2929
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect

go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR
1212
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
1313
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
1414
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
15-
github.com/yyle88/done v1.0.25 h1:zBOFbByEybPited1OZcF+VMaZF5lSTueBgGeTCLH6XA=
16-
github.com/yyle88/done v1.0.25/go.mod h1:ATFPtqXx5TgRuk0abvGQivAA1yupqKAq6gogUNBYb4s=
17-
github.com/yyle88/erero v1.0.20 h1:S561vG3urdQ1pM6Se2/x8OQicrmVxnlWe9J7rC+WPvU=
18-
github.com/yyle88/erero v1.0.20/go.mod h1:nbNNXS09v4YZop/nYswXuxvnga874h6tjYOcDGYKKuA=
19-
github.com/yyle88/eroticgo v0.0.3 h1:UMX4b1rFpu0GZQRhTmRLEbVuDBCle0BYt+kDGgxGc1s=
20-
github.com/yyle88/eroticgo v0.0.3/go.mod h1:e748J+JnGHnPrHVExVb14VzmYjaJelyhnAzzi5JF/GQ=
21-
github.com/yyle88/formatgo v1.0.23 h1:RrLxVGbv2aLbkfjpm97YYOpxD8fdTC1CwkggdNlRCFU=
22-
github.com/yyle88/formatgo v1.0.23/go.mod h1:I0yhAaSqWiIjBe98wL+rzgepj3F8GWYF8He+VWneQ2Q=
23-
github.com/yyle88/must v0.0.21 h1:41Aut43SyJWcblpVRcAFKjcPHzkCkUuR8uI3Q/VB/do=
24-
github.com/yyle88/must v0.0.21/go.mod h1:XJZYd/+pV35O7ul12q8w47dBDRtOWJESZKTi5PbyTEc=
15+
github.com/yyle88/done v1.0.26 h1:lncTfGVFZWDV+ni9kgJWXjwl9qryVrX5xBYKW1Os1yg=
16+
github.com/yyle88/done v1.0.26/go.mod h1:Y/QHJS7guYtGMnbar4SHXGUtwUqckomTmRBaCcwW/y4=
17+
github.com/yyle88/erero v1.0.21 h1:SlVxmw1PsIXKkx23MojbrkYT4LtLEvSx+ZbDCDJ6ijE=
18+
github.com/yyle88/erero v1.0.21/go.mod h1:JH9yodnM7L9/0mCIkwwSXinLG1KY9xaaPGZRShJNTfw=
19+
github.com/yyle88/eroticgo v0.0.4 h1:ovmaRGWM8iN6P2uGlGNXaP8dVoWloLvYmC5Ta9rBNnM=
20+
github.com/yyle88/eroticgo v0.0.4/go.mod h1:e748J+JnGHnPrHVExVb14VzmYjaJelyhnAzzi5JF/GQ=
21+
github.com/yyle88/formatgo v1.0.24 h1:jdH+LkQ8vDozh/1YM5TnIUKN3okts90E/UgNBaqpY/w=
22+
github.com/yyle88/formatgo v1.0.24/go.mod h1:0Iaj84Kw5slGwGMXK46EyHpsiutpA6e2Lct+J5MOooY=
23+
github.com/yyle88/must v0.0.25 h1:SF1wAYNTfupFNfnXJcnizLZAJtCUCJf2dUVY/9nvtUQ=
24+
github.com/yyle88/must v0.0.25/go.mod h1:SE9pZwrZLt8+wnWJJEAve5QKOm8rz3lSxokUxGGgemo=
2525
github.com/yyle88/mutexmap v1.0.13 h1:wp/6mv/gsC2DSqNbhMYiil4gtnb0sDCIhHHIHK2h0cQ=
2626
github.com/yyle88/mutexmap v1.0.13/go.mod h1:QUYDuARLPlGj414kHewQ5tt8jkDxQXoai8H3C4Gg+yc=
27-
github.com/yyle88/osexec v0.0.27 h1:idPnc49uXPeU/A1Osn/ZwM3ViP792c5nxZHqTLWuarA=
28-
github.com/yyle88/osexec v0.0.27/go.mod h1:edWVMCfUjE6SpLrbkngJM+W+HCzUZysRVlWMT/woHQE=
27+
github.com/yyle88/osexec v0.0.31 h1:nMJLAv7r0mB1wKrD7njA+Kf2qlujtDDPu+SXy80Z4a0=
28+
github.com/yyle88/osexec v0.0.31/go.mod h1:YEJgsqvZ6vZc85nZaiU8NiFwCPuk0GGbkCKSrMxFtpQ=
2929
github.com/yyle88/osexistpath v0.0.17 h1:+F206hMCYMRcGweKoYNRRDgcWolZgKRYzGrDYd9O2n4=
3030
github.com/yyle88/osexistpath v0.0.17/go.mod h1:+t1m80g/LiZwCiQjalOVuNXVtejsvxqcImj63a/LYhw=
3131
github.com/yyle88/printgo v1.0.5 h1:gmaJKzEkrH6adbgfOfS6xq02CdvsE8QF+uKXXOdVLN8=
@@ -36,12 +36,12 @@ github.com/yyle88/runpath v1.0.23 h1:VEdeaMXfvFY7CuF9Nceuxb6HSNDcmiSSGEf+zT7O900
3636
github.com/yyle88/runpath v1.0.23/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg=
3737
github.com/yyle88/sure v0.0.38 h1:+yw3++UKizkh7JsBtoZKH6jC2K1Jr4Z2U088zYBLJ/w=
3838
github.com/yyle88/sure v0.0.38/go.mod h1:zkSgOlFeW4xETRZNoR0GZ2v/q7wxnlHl3dxI4f4tftI=
39-
github.com/yyle88/syntaxgo v0.0.48 h1:JbyUnpq1pnf/hXgkfQ65bGMzJh/EVOvkXR7TtqjcpgQ=
40-
github.com/yyle88/syntaxgo v0.0.48/go.mod h1:Zx2vsDL+025u78thQwDqM6z33t7/czEuRAOzRvVsGxk=
41-
github.com/yyle88/tern v0.0.7 h1:Jn0euy+JY1OpdN7TpSknTVNbhxqMjaZEacyFHPPNAEw=
42-
github.com/yyle88/tern v0.0.7/go.mod h1:g9weyOMLtXYyt37EAshZPUTTHdH7WFauuxDi4oPr7/8=
43-
github.com/yyle88/zaplog v0.0.22 h1:hozMmQ0bhXLS6bkR3yHwW5cH8YelK09Df3lhy1k3iMM=
44-
github.com/yyle88/zaplog v0.0.22/go.mod h1:lOdA2Ju4Alify777G8AvdZVqfCPUEpkWjsLgEOkVfS4=
39+
github.com/yyle88/syntaxgo v0.0.52 h1:G3A9MyTHp82j1Y2LPYqtD3lv/slutJ9/nVW/yi4XG4E=
40+
github.com/yyle88/syntaxgo v0.0.52/go.mod h1:wODs8eDwW75ARUJ9PBDBxOvot/Gj01gXPmsFQouTWsU=
41+
github.com/yyle88/tern v0.0.8 h1:Qn6dpYNbYA8bhPX/SjQHnML0MIoKScGNRgGH+VFox1U=
42+
github.com/yyle88/tern v0.0.8/go.mod h1:g9weyOMLtXYyt37EAshZPUTTHdH7WFauuxDi4oPr7/8=
43+
github.com/yyle88/zaplog v0.0.24 h1:8/G2Id1H2wSiQKav4e4vipB8LFeFlIYicTsv4sQO6wQ=
44+
github.com/yyle88/zaplog v0.0.24/go.mod h1:3eaCIi66BgCHh5IIbHlvuRWJPXz89m/EDPfqLe7p6Us=
4545
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
4646
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
4747
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=

new_git.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ type Gcm struct {
1414
}
1515

1616
func New(path string) *Gcm {
17-
return newOkGcm(osexec.NewCommandConfig().WithPath(path).WithDebugMode(debugModeOpen), make([]byte, 0), debugModeOpen)
17+
return newOkGcm(osexec.NewCommandConfig().WithPath(path).WithDebugMode(osexec.NewDebugMode(debugModeOpen)), make([]byte, 0), debugModeOpen)
1818
}
1919

2020
func NewGcm(path string, execConfig *osexec.ExecConfig) *Gcm {
21-
return newOkGcm(execConfig.ShallowClone().WithPath(path).WithDebugMode(debugModeOpen), make([]byte, 0), debugModeOpen)
21+
return newOkGcm(execConfig.NewConfig().WithPath(path).WithDebugMode(osexec.NewDebugMode(debugModeOpen)), make([]byte, 0), debugModeOpen)
2222
}
2323

2424
func newOkGcm(execConfig *osexec.ExecConfig, output []byte, debugMode bool) *Gcm {
@@ -85,7 +85,7 @@ func (G *Gcm) WithDebug() *Gcm {
8585

8686
func (G *Gcm) WithDebugMode(debugMode bool) *Gcm {
8787
G.debugMode = debugMode
88-
G.execConfig.WithDebugMode(debugMode)
88+
G.execConfig.WithDebugMode(osexec.NewDebugMode(debugMode))
8989
return G
9090
}
9191

0 commit comments

Comments
 (0)