Skip to content

Commit ca53b02

Browse files
committed
Update tools.go
1 parent 8b9ff4d commit ca53b02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fix/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func GitConfig(ctx context.Context, path, repoPath, branch, gitRemote, commitHas
111111
// 检测分支是否存在
112112
func CheckBranchExist(ctx context.Context, repoPath, branch string) (bool, error) {
113113

114-
cmd := exec.CommandContext(ctx, "git", "branch", "-a", "|", "grep", "remotes/origin/"+branch)
114+
cmd := exec.CommandContext(ctx, "git", "show-branch", "origin/"+branch)
115115
cmd.Dir = repoPath
116116
out, err := cmd.Output()
117117

@@ -128,7 +128,7 @@ func CheckBranchExist(ctx context.Context, repoPath, branch string) (bool, error
128128
if len(string(out)) == 0 {
129129
return false, errors.New("无法获得检测分支")
130130
}
131-
if strings.ReplaceAll(string(out), "remotes/origin/", "") != branch {
131+
if strings.Contains(string(out), "fatal: bad sha1 reference") {
132132
return false, errors.New("无法获得检测分支")
133133

134134
}

0 commit comments

Comments
 (0)