Skip to content

Commit

Permalink
Update tools.go
Browse files Browse the repository at this point in the history
  • Loading branch information
645775992 committed Nov 15, 2023
1 parent 8b9ff4d commit ca53b02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fix/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GitConfig(ctx context.Context, path, repoPath, branch, gitRemote, commitHas
// 检测分支是否存在
func CheckBranchExist(ctx context.Context, repoPath, branch string) (bool, error) {

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

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

}
Expand Down

0 comments on commit ca53b02

Please sign in to comment.