We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d93d5d7 commit 6cb9ce1Copy full SHA for 6cb9ce1
modules/git/repo_branch.go
@@ -28,8 +28,14 @@ func IsBranchExist(repoPath, name string) bool {
28
29
// IsBranchExist returns true if given branch exists in current repository.
30
func (repo *Repository) IsBranchExist(name string) bool {
31
- _, err := repo.gogitRepo.Reference(plumbing.ReferenceName(BranchPrefix+name), true)
32
- return err == nil
+ if name == "" {
+ return false
33
+ }
34
+ reference, err := repo.gogitRepo.Reference(plumbing.ReferenceName(BranchPrefix+name), true)
35
+ if err != nil {
36
37
38
+ return reference.Type() != plumbing.InvalidReference
39
}
40
41
// Branch represents a Git branch.
0 commit comments