mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	* IsBranchExist: return false if provided name is empty * Ensure that the reference returned is actually of a valid type
This commit is contained in:
		@@ -28,8 +28,14 @@ func IsBranchExist(repoPath, name string) bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// IsBranchExist returns true if given branch exists in current repository.
 | 
					// IsBranchExist returns true if given branch exists in current repository.
 | 
				
			||||||
func (repo *Repository) IsBranchExist(name string) bool {
 | 
					func (repo *Repository) IsBranchExist(name string) bool {
 | 
				
			||||||
	_, err := repo.gogitRepo.Reference(plumbing.ReferenceName(BranchPrefix+name), true)
 | 
						if name == "" {
 | 
				
			||||||
	return err == nil
 | 
							return false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						reference, err := repo.gogitRepo.Reference(plumbing.ReferenceName(BranchPrefix+name), true)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return reference.Type() != plumbing.InvalidReference
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Branch represents a Git branch.
 | 
					// Branch represents a Git branch.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user