On tag/branch-exist check, dont panic if repo is nil (#21787)

fix a panic found in gitea logs
pull/21775/head^2
6543 2 years ago committed by GitHub
parent 36cbaec54c
commit 46485848fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/git/repo_branch_nogogit.go
  2. 2
      modules/git/repo_tag_nogogit.go

@ -52,7 +52,7 @@ func (repo *Repository) IsReferenceExist(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 {
if name == "" { if repo == nil || name == "" {
return false return false
} }

@ -15,7 +15,7 @@ import (
// IsTagExist returns true if given tag exists in the repository. // IsTagExist returns true if given tag exists in the repository.
func (repo *Repository) IsTagExist(name string) bool { func (repo *Repository) IsTagExist(name string) bool {
if name == "" { if repo == nil || name == "" {
return false return false
} }

Loading…
Cancel
Save