41
41
echo "$res"
42
42
fi
43
43
`
44
- output , err := G .execConfig .ShallowClone ().WithBash ().Exec (strings .TrimSpace (commandBash ))
44
+ output , err := G .execConfig .NewConfig ().WithBash ().Exec (strings .TrimSpace (commandBash ))
45
45
if err != nil {
46
46
return "" , erero .Wro (err )
47
47
}
@@ -63,7 +63,7 @@ echo "$res"
63
63
commandBash := fmt .Sprintf (commandBashTemplate , regexp .QuoteMeta (prefix ))
64
64
65
65
// 存在问题,就是标签是打在commit提交上面的,因此在相同的提交上打多个标签时,他们的时间是相同的,这时候取到的,有可能不是最新的那个标签
66
- output , err := G .execConfig .ShallowClone ().WithBash ().Exec (strings .TrimSpace (commandBash ))
66
+ output , err := G .execConfig .NewConfig ().WithBash ().Exec (strings .TrimSpace (commandBash ))
67
67
if err != nil {
68
68
return "" , erero .Wro (err )
69
69
}
@@ -85,7 +85,7 @@ echo "$res"
85
85
commandBash := fmt .Sprintf (commandBashTemplate , regexp .QuoteMeta (regexpPattern ))
86
86
87
87
// 存在问题,就是标签是打在commit提交上面的,因此在相同的提交上打多个标签时,他们的时间是相同的,这时候取到的,有可能不是最新的那个标签
88
- output , err := G .execConfig .ShallowClone ().WithBash ().Exec (strings .TrimSpace (commandBash ))
88
+ output , err := G .execConfig .NewConfig ().WithBash ().Exec (strings .TrimSpace (commandBash ))
89
89
if err != nil {
90
90
return "" , erero .Wro (err )
91
91
}
@@ -104,7 +104,7 @@ func (G *Gcm) GitCommitHash(refName string) (string, error) {
104
104
// SortedGitTags 获取项目的标签列表,按时间从前到后排列。使用场景是仅仅观察标签,让用户自己想出下一个标签的序号,因此这里只返回个字符串就行
105
105
func (G * Gcm ) SortedGitTags () (string , error ) {
106
106
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 ))
108
108
if err != nil {
109
109
return "" , erero .Wro (err )
110
110
}
@@ -114,7 +114,7 @@ func (G *Gcm) SortedGitTags() (string, error) {
114
114
// GetTopPath 获取 git 项目的根目录
115
115
func (G * Gcm ) GetTopPath () (string , error ) {
116
116
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 ))
118
118
if err != nil {
119
119
return "" , erero .Wro (err )
120
120
}
@@ -124,7 +124,7 @@ func (G *Gcm) GetTopPath() (string, error) {
124
124
// GetGitDirAbsPath 获取 git 项目的 .git 目录的绝对路径(如 "/home/user/project/.git")
125
125
func (G * Gcm ) GetGitDirAbsPath () (string , error ) {
126
126
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 ))
128
128
if err != nil {
129
129
return "" , erero .Wro (err )
130
130
}
@@ -134,7 +134,7 @@ func (G *Gcm) GetGitDirAbsPath() (string, error) {
134
134
// GetSubPathToRoot 获取从当前目录到 git 项目根目录的相对路径(如 "../",如果在根目录则为空字符串)
135
135
func (G * Gcm ) GetSubPathToRoot () (string , error ) {
136
136
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 ))
138
138
if err != nil {
139
139
return "" , erero .Wro (err )
140
140
}
@@ -144,7 +144,7 @@ func (G *Gcm) GetSubPathToRoot() (string, error) {
144
144
// GetSubPath 获取从 git 项目根目录到当前目录的相对路径(如 "subdir",如果在根目录则为空字符串)
145
145
func (G * Gcm ) GetSubPath () (string , error ) {
146
146
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 ))
148
148
if err != nil {
149
149
return "" , erero .Wro (err )
150
150
}
0 commit comments